packages feed

diagrams-graphviz 1.4 → 1.4.1

raw patch · 3 files changed

+44/−11 lines, 3 filesdep ~basedep ~fgldep ~graphvizPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: base, fgl, graphviz

API changes (from Hackage documentation)

+ Diagrams.TwoD.GraphViz: EdgesOnTop :: GraphLayering
+ Diagrams.TwoD.GraphViz: VerticesOnTop :: GraphLayering
+ Diagrams.TwoD.GraphViz: data GraphLayering
+ Diagrams.TwoD.GraphViz: drawGraph' :: (Ord v, Semigroup m) => GraphLayering -> (v -> P2 Double -> QDiagram b V2 Double m) -> (v -> P2 Double -> v -> P2 Double -> e -> Path V2 Double -> QDiagram b V2 Double m) -> Gr (AttributeNode v) (AttributeEdge e) -> QDiagram b V2 Double m
+ Diagrams.TwoD.GraphViz: instance GHC.Classes.Eq Diagrams.TwoD.GraphViz.GraphLayering
+ Diagrams.TwoD.GraphViz: instance GHC.Classes.Ord Diagrams.TwoD.GraphViz.GraphLayering
+ Diagrams.TwoD.GraphViz: instance GHC.Read.Read Diagrams.TwoD.GraphViz.GraphLayering
+ Diagrams.TwoD.GraphViz: instance GHC.Show.Show Diagrams.TwoD.GraphViz.GraphLayering
- Diagrams.TwoD.GraphViz: drawGraph :: (Ord v, Semigroup m) => (v -> P2 Double -> QDiagram b V2 Double m) -> (v -> P2 Double -> v -> P2 Double -> e -> Path V2 Double -> QDiagram b V2 Double m) -> Gr (AttributeNode v) (AttributeNode e) -> QDiagram b V2 Double m
+ Diagrams.TwoD.GraphViz: drawGraph :: (Ord v, Semigroup m) => (v -> P2 Double -> QDiagram b V2 Double m) -> (v -> P2 Double -> v -> P2 Double -> e -> Path V2 Double -> QDiagram b V2 Double m) -> Gr (AttributeNode v) (AttributeEdge e) -> QDiagram b V2 Double m
- Diagrams.TwoD.GraphViz: getGraph :: Ord v => Gr (AttributeNode v) (AttributeNode e) -> (Map v (P2 Double), [(v, v, e, Path V2 Double)])
+ Diagrams.TwoD.GraphViz: getGraph :: Ord v => Gr (AttributeNode v) (AttributeEdge e) -> (Map v (P2 Double), [(v, v, e, Path V2 Double)])

Files

CHANGES.markdown view
@@ -1,3 +1,10 @@+1.4.1 (28 May 2018)+-------------------++- add new `drawGraph'` function which allows specifying whether edges+  or vertices should be layered on top.+- allow `base-4.11`, `fgl-5.6`, and `graphviz-2999.20`.+ 1.4 (27 Oct 2016) ----------------- 
diagrams-graphviz.cabal view
@@ -1,5 +1,5 @@ name:                diagrams-graphviz-version:             1.4+version:             1.4.1 synopsis:            Graph layout and drawing with GrahpViz and diagrams description:         Use GraphViz and diagrams together, with each doing what                      it does best: GraphViz for laying out graphs, and diagrams@@ -14,7 +14,7 @@ build-type:          Simple extra-source-files:  README.markdown, CHANGES.markdown cabal-version:       >=1.10-Tested-with:         GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.1+Tested-with:         GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.2 Source-repository head   type:     git   location: git://github.com/diagrams/diagrams-graphviz.git@@ -22,11 +22,11 @@ library   exposed-modules:     Diagrams.TwoD.GraphViz   other-extensions:    FlexibleContexts, MultiParamTypeClasses, NoMonomorphismRestriction-  build-depends:       base >=4.6 && < 4.10,+  build-depends:       base >=4.6 && < 4.12,                        containers >= 0.4 && < 0.6,                        diagrams-lib >= 1.3 && < 1.5,-                       graphviz >= 2999.17 && < 2999.19,-                       fgl >= 5.5 && < 5.6,+                       graphviz >= 2999.17 && < 2999.21,+                       fgl >= 5.5 && < 5.7,                        split >= 0.2 && < 0.3   hs-source-dirs:      src   default-language:    Haskell2010
src/Diagrams/TwoD/GraphViz.hs view
@@ -102,12 +102,14 @@ -----------------------------------------------------------------------------  module Diagrams.TwoD.GraphViz (-    mkGraph+    GraphLayering (..)+  , mkGraph   , layoutGraph   , layoutGraph'   , defaultDiaParams    , drawGraph+  , drawGraph'   , getGraph   , simpleGraphDiagram   ) where@@ -148,7 +150,7 @@ --   control over graph drawing. getGraph   :: Ord v-  => Gr (AttributeNode v) (AttributeNode e)+  => Gr (AttributeNode v) (AttributeEdge e)   -> (M.Map v (P2 Double), [(v, v, e, Path V2 Double)]) getGraph gr = (vmap, edges)   where@@ -183,16 +185,40 @@ --   second function, for each edge, is given the label and location --   of the first vertex, the label and location of the second vertex, --   and the label and path corresponding to the edge.+--+--   Note that, by default, edges are drawn on top of vertices.  To+--   control the placement order, use 'drawGraph''. drawGraph   :: (Ord v, Semigroup m)   => (v -> P2 Double -> QDiagram b V2 Double m)   -> (v -> P2 Double -> v -> P2 Double -> e -> Path V2 Double -> QDiagram b V2 Double m)-  -> Gr (AttributeNode v) (AttributeNode e)+  -> Gr (AttributeNode v) (AttributeEdge e)   -> QDiagram b V2 Double m-drawGraph drawV drawE gr-  = mconcat (map drawE' edges)- <> mconcat (map (uncurry drawV) (M.assocs vmap))+drawGraph = drawGraph' EdgesOnTop++-- | A data type for specifying whether edges should be drawn on top+--   of vertices or vice versa.+data GraphLayering = EdgesOnTop | VerticesOnTop+  deriving (Show, Read, Eq, Ord)++-- | The same as 'drawGraph', but with an extra parameter allowing you+--   to specify whether vertices or edges should be drawn on top.+drawGraph'+  :: (Ord v, Semigroup m)+  => GraphLayering+  -> (v -> P2 Double -> QDiagram b V2 Double m)+  -> (v -> P2 Double -> v -> P2 Double -> e -> Path V2 Double -> QDiagram b V2 Double m)+  -> Gr (AttributeNode v) (AttributeEdge e)+  -> QDiagram b V2 Double m+drawGraph' gl drawV drawE gr+  = case gl of+      EdgesOnTop    -> mconcat components+      VerticesOnTop -> mconcat (reverse components)   where+    components =+      [ mconcat (map drawE' edges)+      , mconcat (map (uncurry drawV) (M.assocs vmap))+      ]     (vmap, edges) = getGraph gr     drawE' (v1,v2,e,p)       = drawE v1 (fromJust $ M.lookup v1 vmap) v2 (fromJust $ M.lookup v2 vmap) e p