graphviz 2999.5.1.1 → 2999.6.0.0
raw patch · 7 files changed
+99/−66 lines, 7 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Data.GraphViz.Attributes: Box3d :: Shape
- Data.GraphViz.Attributes: Doublecircle :: Shape
- Data.GraphViz.Attributes: Doubleoctagon :: Shape
- Data.GraphViz.Attributes: Invhouse :: Shape
- Data.GraphViz.Attributes: Invtrapezium :: Shape
- Data.GraphViz.Attributes: Invtriangle :: Shape
- Data.GraphViz.Attributes: Mcircle :: Shape
- Data.GraphViz.Attributes: Mdiamond :: Shape
- Data.GraphViz.Attributes: Msquare :: Shape
- Data.GraphViz.Attributes: NoShape :: Shape
- Data.GraphViz.Attributes: Plaintext :: Shape
- Data.GraphViz.Attributes: Rectangle :: Shape
- Data.GraphViz.Attributes: Tripleoctagon :: Shape
+ Data.GraphViz.Attributes: Box3D :: Shape
+ Data.GraphViz.Attributes: DoubleCircle :: Shape
+ Data.GraphViz.Attributes: DoubleOctagon :: Shape
+ Data.GraphViz.Attributes: InvHouse :: Shape
+ Data.GraphViz.Attributes: InvTrapezium :: Shape
+ Data.GraphViz.Attributes: InvTriangle :: Shape
+ Data.GraphViz.Attributes: MCircle :: Shape
+ Data.GraphViz.Attributes: MDiamond :: Shape
+ Data.GraphViz.Attributes: MSquare :: Shape
+ Data.GraphViz.Attributes: PlainText :: Shape
+ Data.GraphViz.Attributes: TripleOctagon :: Shape
+ Data.GraphViz.Types.Parsing: stringReps :: a -> [String] -> Parse a
- Data.GraphViz: clusterGraphToDot :: (Ord c, Graph gr) => Bool -> gr a b -> [GlobalAttributes] -> (LNode a -> NodeCluster c a) -> (c -> Maybe GraphID) -> (c -> [GlobalAttributes]) -> (LNode a -> Attributes) -> (LEdge b -> Attributes) -> DotGraph Node
+ Data.GraphViz: clusterGraphToDot :: (Ord c, Graph gr) => Bool -> gr a b -> [GlobalAttributes] -> (LNode a -> NodeCluster c l) -> (c -> Maybe GraphID) -> (c -> [GlobalAttributes]) -> (LNode l -> Attributes) -> (LEdge b -> Attributes) -> DotGraph Node
- Data.GraphViz: clusterGraphToDot' :: (Ord c, Ord b, Graph gr) => gr a b -> [GlobalAttributes] -> (LNode a -> NodeCluster c a) -> (c -> Maybe GraphID) -> (c -> [GlobalAttributes]) -> (LNode a -> Attributes) -> (LEdge b -> Attributes) -> DotGraph Node
+ Data.GraphViz: clusterGraphToDot' :: (Ord c, Ord b, Graph gr) => gr a b -> [GlobalAttributes] -> (LNode a -> NodeCluster c l) -> (c -> Maybe GraphID) -> (c -> [GlobalAttributes]) -> (LNode l -> Attributes) -> (LEdge b -> Attributes) -> DotGraph Node
- Data.GraphViz: clusterGraphToGraph :: (Ord c, Graph gr) => Bool -> gr a b -> [GlobalAttributes] -> (LNode a -> NodeCluster c a) -> (c -> Maybe GraphID) -> (c -> [GlobalAttributes]) -> (LNode a -> Attributes) -> (LEdge b -> Attributes) -> IO (gr (AttributeNode a) (AttributeEdge b))
+ Data.GraphViz: clusterGraphToGraph :: (Ord c, Graph gr) => Bool -> gr a b -> [GlobalAttributes] -> (LNode a -> NodeCluster c l) -> (c -> Maybe GraphID) -> (c -> [GlobalAttributes]) -> (LNode l -> Attributes) -> (LEdge b -> Attributes) -> IO (gr (AttributeNode a) (AttributeEdge b))
- Data.GraphViz: clusterGraphToGraph' :: (Ord b, Ord c, Graph gr) => gr a b -> [GlobalAttributes] -> (LNode a -> NodeCluster c a) -> (c -> Maybe GraphID) -> (c -> [GlobalAttributes]) -> (LNode a -> Attributes) -> (LEdge b -> Attributes) -> IO (gr (AttributeNode a) (AttributeEdge b))
+ Data.GraphViz: clusterGraphToGraph' :: (Ord b, Ord c, Graph gr) => gr a b -> [GlobalAttributes] -> (LNode a -> NodeCluster c l) -> (c -> Maybe GraphID) -> (c -> [GlobalAttributes]) -> (LNode l -> Attributes) -> (LEdge b -> Attributes) -> IO (gr (AttributeNode a) (AttributeEdge b))
- Data.GraphViz: dotizeClusterGraph :: (Ord c, Graph gr) => Bool -> gr a b -> (LNode a -> NodeCluster c a) -> gr (AttributeNode a) (AttributeEdge b)
+ Data.GraphViz: dotizeClusterGraph :: (Ord c, Graph gr) => Bool -> gr a b -> (LNode a -> NodeCluster c l) -> gr (AttributeNode a) (AttributeEdge b)
- Data.GraphViz: dotizeClusterGraph' :: (Ord b, Ord c, Graph gr) => gr a b -> (LNode a -> NodeCluster c a) -> gr (AttributeNode a) (AttributeEdge b)
+ Data.GraphViz: dotizeClusterGraph' :: (Ord b, Ord c, Graph gr) => gr a b -> (LNode a -> NodeCluster c l) -> gr (AttributeNode a) (AttributeEdge b)
Files
- Changelog +10/−0
- Data/GraphViz.hs +11/−11
- Data/GraphViz/Attributes.hs +35/−41
- Data/GraphViz/Types.hs +34/−9
- Data/GraphViz/Types/Clustering.hs +2/−2
- Data/GraphViz/Types/Parsing.hs +6/−2
- graphviz.cabal +1/−1
Changelog view
@@ -1,3 +1,13 @@+Changes in 2999.6.0.0+=====================++* Remove some Shape aliases and change capitalisation of others.++* Properly parse and print IDs of clusters.++* Allow NodeCluster values have node types different from the LNode+ they come from.+ Changes in 2999.5.1.1 =====================
Data/GraphViz.hs view
@@ -105,9 +105,9 @@ -- Clusters can be nested to arbitrary depth. -- The 'Bool' argument is 'True' for directed graphs, 'False' otherwise. clusterGraphToDot :: (Ord c, Graph gr) => Bool -> gr a b- -> [GlobalAttributes] -> (LNode a -> NodeCluster c a)+ -> [GlobalAttributes] -> (LNode a -> NodeCluster c l) -> (c -> Maybe GraphID) -> (c -> [GlobalAttributes])- -> (LNode a -> Attributes) -> (LEdge b -> Attributes)+ -> (LNode l -> Attributes) -> (LEdge b -> Attributes) -> DotGraph Node clusterGraphToDot dirGraph graph gAttrs clusterBy cID fmtCluster fmtNode fmtEdge = DotGraph { strictGraph = False@@ -136,9 +136,9 @@ -- Clusters can be nested to arbitrary depth. -- Graph direction is automatically inferred. clusterGraphToDot' :: (Ord c, Ord b, Graph gr) => gr a b- -> [GlobalAttributes] -> (LNode a -> NodeCluster c a)+ -> [GlobalAttributes] -> (LNode a -> NodeCluster c l) -> (c -> Maybe GraphID) -> (c -> [GlobalAttributes])- -> (LNode a -> Attributes) -> (LEdge b -> Attributes)+ -> (LNode l -> Attributes) -> (LEdge b -> Attributes) -> DotGraph Node clusterGraphToDot' gr = clusterGraphToDot (isDirected gr) gr @@ -175,7 +175,7 @@ rnf s `seq` return s rebuildGraphWithAttributes dotResult = mkGraph lnodes ledges where- lnodes = map (\(n, l) -> (n, (fromJust $ Map.lookup n nodeMap, l)))+ lnodes = map (\(n, l) -> (n, (nodeMap Map.! n, l))) $ labNodes gr ledges = map createEdges $ labEdges gr createEdges (f, t, l) = if isDir || f <= t@@ -210,9 +210,9 @@ -- otherwise. Directed graphs are passed through /dot/, and -- undirected graphs through /neato/. clusterGraphToGraph :: (Ord c, Graph gr) => Bool -> gr a b- -> [GlobalAttributes] -> (LNode a -> NodeCluster c a)+ -> [GlobalAttributes] -> (LNode a -> NodeCluster c l) -> (c -> Maybe GraphID) -> (c -> [GlobalAttributes])- -> (LNode a -> Attributes) -> (LEdge b -> Attributes)+ -> (LNode l -> Attributes) -> (LEdge b -> Attributes) -> IO (gr (AttributeNode a) (AttributeEdge b)) clusterGraphToGraph isDir gr gAtts clBy cID fmtClust fmtNode fmtEdge = dotAttributes isDir gr dot@@ -225,9 +225,9 @@ -- -- Graph direction is automatically inferred. clusterGraphToGraph' :: (Ord b, Ord c, Graph gr) => gr a b- -> [GlobalAttributes] -> (LNode a -> NodeCluster c a)+ -> [GlobalAttributes] -> (LNode a -> NodeCluster c l) -> (c -> Maybe GraphID) -> (c -> [GlobalAttributes])- -> (LNode a -> Attributes) -> (LEdge b -> Attributes)+ -> (LNode l -> Attributes) -> (LEdge b -> Attributes) -> IO (gr (AttributeNode a) (AttributeEdge b)) clusterGraphToGraph' gr = clusterGraphToGraph (isDirected gr) gr @@ -267,7 +267,7 @@ -- otherwise. Directed graphs are passed through /dot/, and -- undirected graphs through /neato/. dotizeClusterGraph :: (Ord c, Graph gr) => Bool -> gr a b- -> (LNode a -> NodeCluster c a)+ -> (LNode a -> NodeCluster c l) -> gr (AttributeNode a) (AttributeEdge b) dotizeClusterGraph isDir g clustBy = unsafePerformIO $ clusterGraphToGraph isDir g@@ -287,6 +287,6 @@ -- -- The graph direction is automatically inferred. dotizeClusterGraph' :: (Ord b, Ord c, Graph gr) => gr a b- -> (LNode a -> NodeCluster c a)+ -> (LNode a -> NodeCluster c l) -> gr (AttributeNode a) (AttributeEdge b) dotizeClusterGraph' g = dotizeClusterGraph (isDirected g) g
Data/GraphViz/Attributes.hs view
@@ -1773,14 +1773,14 @@ -- ----------------------------------------------------------------------------- data Shape- = BoxShape+ = BoxShape -- ^ Has synonyms of /rect/ and /rectangle/. | Polygon | Ellipse | Circle | PointShape | Egg | Triangle- | Plaintext+ | PlainText -- ^ Has synonym of /none/. | DiamondShape | Trapezium | Parallelogram@@ -1789,21 +1789,19 @@ | Hexagon | Septagon | Octagon- | Doublecircle- | Doubleoctagon- | Tripleoctagon- | Invtriangle- | Invtrapezium- | Invhouse- | Mdiamond- | Msquare- | Mcircle- | Rectangle- | NoShape+ | DoubleCircle+ | DoubleOctagon+ | TripleOctagon+ | InvTriangle+ | InvTrapezium+ | InvHouse+ | MDiamond+ | MSquare+ | MCircle | Note | Tab | Folder- | Box3d+ | Box3D | Component deriving (Eq, Show, Read) @@ -1815,7 +1813,7 @@ unqtDot PointShape = text "point" unqtDot Egg = text "egg" unqtDot Triangle = text "triangle"- unqtDot Plaintext = text "plaintext"+ unqtDot PlainText = text "plaintext" unqtDot DiamondShape = text "diamond" unqtDot Trapezium = text "trapezium" unqtDot Parallelogram = text "parallelogram"@@ -1824,32 +1822,30 @@ unqtDot Hexagon = text "hexagon" unqtDot Septagon = text "septagon" unqtDot Octagon = text "octagon"- unqtDot Doublecircle = text "doublecircle"- unqtDot Doubleoctagon = text "doubleoctagon"- unqtDot Tripleoctagon = text "tripleoctagon"- unqtDot Invtriangle = text "invtriangle"- unqtDot Invtrapezium = text "invtrapezium"- unqtDot Invhouse = text "invhouse"- unqtDot Mdiamond = text "Mdiamond"- unqtDot Msquare = text "Msquare"- unqtDot Mcircle = text "Mcircle"- unqtDot Rectangle = text "rectangle"- unqtDot NoShape = text "none"+ unqtDot DoubleCircle = text "doublecircle"+ unqtDot DoubleOctagon = text "doubleoctagon"+ unqtDot TripleOctagon = text "tripleoctagon"+ unqtDot InvTriangle = text "invtriangle"+ unqtDot InvTrapezium = text "invtrapezium"+ unqtDot InvHouse = text "invhouse"+ unqtDot MDiamond = text "Mdiamond"+ unqtDot MSquare = text "Msquare"+ unqtDot MCircle = text "Mcircle" unqtDot Note = text "note" unqtDot Tab = text "tab" unqtDot Folder = text "folder"- unqtDot Box3d = text "box3d"+ unqtDot Box3D = text "box3d" unqtDot Component = text "component" instance ParseDot Shape where- parseUnqt = oneOf [ stringRep BoxShape "box"+ parseUnqt = oneOf [ stringReps BoxShape ["box","rect","rectangle"] , stringRep Polygon "polygon" , stringRep Ellipse "ellipse" , stringRep Circle "circle" , stringRep PointShape "point" , stringRep Egg "egg" , stringRep Triangle "triangle"- , stringRep Plaintext "plaintext"+ , stringReps PlainText ["plaintext","none"] , stringRep DiamondShape "diamond" , stringRep Trapezium "trapezium" , stringRep Parallelogram "parallelogram"@@ -1858,21 +1854,19 @@ , stringRep Hexagon "hexagon" , stringRep Septagon "septagon" , stringRep Octagon "octagon"- , stringRep Doublecircle "doublecircle"- , stringRep Doubleoctagon "doubleoctagon"- , stringRep Tripleoctagon "tripleoctagon"- , stringRep Invtriangle "invtriangle"- , stringRep Invtrapezium "invtrapezium"- , stringRep Invhouse "invhouse"- , stringRep Mdiamond "Mdiamond"- , stringRep Msquare "Msquare"- , stringRep Mcircle "Mcircle"- , stringRep Rectangle "rectangle"- , stringRep NoShape "none"+ , stringRep DoubleCircle "doublecircle"+ , stringRep DoubleOctagon "doubleoctagon"+ , stringRep TripleOctagon "tripleoctagon"+ , stringRep InvTriangle "invtriangle"+ , stringRep InvTrapezium "invtrapezium"+ , stringRep InvHouse "invhouse"+ , stringRep MDiamond "Mdiamond"+ , stringRep MSquare "Msquare"+ , stringRep MCircle "Mcircle" , stringRep Note "note" , stringRep Tab "tab" , stringRep Folder "folder"- , stringRep Box3d "box3d"+ , stringRep Box3D "box3d" , stringRep Component "component" ]
Data/GraphViz/Types.hs view
@@ -20,7 +20,17 @@ * When creating 'GraphID' values for 'graphID' and 'subGraphID', you should ensure that none of them have the same printed value as one of the 'nodeID' values to avoid any possible problems.+ Note that if the 'DotSubGraph' has @'isCluster' = 'True'@ then+ this isn't a problem. + * If you want any 'GlobalAttributes' in a 'DotSubGraph' and want+ them to only apply to that 'DotSubGraph', then you must ensure it+ does indeed have a valid 'GraphID'.++ * If eventually outputting to a format such as SVG, then you should+ make sure that your 'DotGraph' has a 'graphID', as that is used+ as the title of the resulting image.+ * Whilst 'DotGraph', etc. are polymorphic in their node type, you should ensure that you use a relatively simple node type (that is, it only covers a single line, etc.).@@ -398,13 +408,20 @@ printSubGraphID :: DotSubGraph a -> DotCode printSubGraphID s = sGraph'- <+> bool clust' empty isCl- <> maybe empty dtID (subGraphID s)+ <+> maybe cl dtID (subGraphID s) where isCl = isCluster s- dtID sId = bool (char '_') space isCl- <> toDot sId+ cl = bool clust' empty isCl+ dtID = printSGID isCl +-- | Print the actual ID for a 'DotSubGraph'.+printSGID :: Bool -> GraphID -> DotCode+printSGID isCl sID = bool addClust noClust isCl+ where+ noClust = toDot sID+ addClust = toDot . (++) clust . (:) '_'+ . renderDot $ unqtDot sID+ instance (ParseDot a) => ParseDot (DotSubGraph a) where parseUnqt = parseStmtBased parseSubGraphID @@ -419,11 +436,19 @@ parseSubGraphID :: Parse (DotStatements a -> DotSubGraph a) parseSubGraphID = do string sGraph whitespace'- isCl <- liftM isJust- $ optional (string clust)- `discard` optional (character '_')- sId <- optional parse- return $ DotSG isCl sId+ (isCl,sID) <- parseSGID+ return $ DotSG isCl sID++parseSGID :: Parse (Bool, Maybe GraphID)+parseSGID = do s <- parse+ return (fst $ runParser pStr s)+ `onFail`+ liftM (flip (,) Nothing) checkCl+ where+ checkCl = liftM isJust $ optional (string clust)+ pStr = do isCl <- checkCl `discard`optional (character '_')+ sID <- parseUnqt+ return (isCl, Just sID) sGraph :: String sGraph = "subgraph"
Data/GraphViz/Types/Clustering.hs view
@@ -32,9 +32,9 @@ deriving (Show) -- | Create the /Dot/ representation for the given graph.-clustersToNodes :: (Ord c, Graph gr) => (LNode a -> NodeCluster c a)+clustersToNodes :: (Ord c, Graph gr) => (LNode a -> NodeCluster c l) -> (c -> Maybe GraphID) -> (c -> [GlobalAttributes])- -> (LNode a -> Attributes) -> gr a b+ -> (LNode l -> Attributes) -> gr a b -> ([DotSubGraph Node], [DotNode Node]) clustersToNodes clusterBy cID fmtCluster fmtNode = treesToDot cID fmtCluster fmtNode
Data/GraphViz/Types/Parsing.hs view
@@ -56,6 +56,7 @@ , commaSepUnqt , commaSep' , stringRep+ , stringReps -- * Pre-processing , preprocess ) where@@ -206,8 +207,11 @@ string :: String -> Parse String string = mapM character -stringRep :: a -> String -> Parse a-stringRep v s = string s >> return v+stringRep :: a -> String -> Parse a+stringRep v = stringReps v . return++stringReps :: a -> [String] -> Parse a+stringReps v ss = (oneOf $ map string ss) >> return v strings :: [String] -> Parse String strings = oneOf . map string
graphviz.cabal view
@@ -1,5 +1,5 @@ Name: graphviz-Version: 2999.5.1.1+Version: 2999.6.0.0 Stability: Beta Synopsis: GraphViz bindings for Haskell. Description: Provides convenient functions to convert FGL