| Maintainer | Ivan.Miljenovic@gmail.com |
|---|
Data.GraphViz.Types
Contents
Description
This module defines the overall types and methods that interact with them for the GraphViz library. The specifications are based loosely upon the information available at: http://graphviz.org/doc/info/lang.html
Printing of Dot code is done as strictly as possible, whilst
parsing is as permissive as possible. For example, if the types
allow it then "2" will be parsed as an Int value. Note that
quoting and escaping of String values is done automagically.
A summary of known limitations/differences:
- When creating
GraphIDvalues forgraphIDandsubGraphID, you should ensure that none of them have the same printed value as one of thenodeIDvalues to avoid any possible problems. - 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.). - Also, whilst GraphViz allows you to mix the types used for nodes, this library requires/assumes that they are all the same type.
-
DotEdgedefines an edge(a, b)(with an edge going fromatob); in Dot parlance the edge has a head ataand a tail atb. Care must be taken when using the relatedHead*andTail*Attributes. See the differences section in Data.GraphViz.Attributes for more information. - It is common to see multiple edges defined on the one line in Dot
(e.g.
n1 -> n2 -> n3means to create a directed edge fromn1ton2and fromn2ton3). These types of edge definitions are parseable; however, they are converted to singleton edges. - Cannot create edges with subgraphs/clusters as one of the end points.
- When either creating a
DotGraphby hand or parsing one, it is possible to specify that, butdirectedGraph= dDotEdgevalues with.directedEdge=notd - Nodes cannot have Port values.
- Cannot place items in an arbitrary order: in particular, this means that it is not possible to use the normal GraphViz hack of having graph attributes that do not apply to subgraphs/clusters by listing them after the subgraphs/clusters.
- The parser will strip out comments and convert multiline strings
into a single line string. Pre-processor lines (i.e. those
started by
#) and string concatenation are not yet supported.
See Data.GraphViz.Attributes for more limitations.
- data DotGraph a = DotGraph {}
- printDotGraph :: PrintDot a => DotGraph a -> String
- parseDotGraph :: ParseDot a => String -> DotGraph a
- setID :: GraphID -> DotGraph a -> DotGraph a
- makeStrict :: DotGraph a -> DotGraph a
- graphNodes :: DotGraph a -> [DotNode a]
- graphEdges :: DotGraph a -> [DotEdge a]
- data DotError a
- isValidGraph :: DotGraph a -> Bool
- graphErrors :: DotGraph a -> [DotError a]
- data GraphID
- data DotStatements a = DotStmts {
- attrStmts :: [GlobalAttributes]
- subGraphs :: [DotSubGraph a]
- nodeStmts :: [DotNode a]
- edgeStmts :: [DotEdge a]
- data GlobalAttributes
- = GraphAttrs {
- attrs :: Attributes
- | NodeAttrs {
- attrs :: Attributes
- | EdgeAttrs {
- attrs :: Attributes
- = GraphAttrs {
- data DotSubGraph a = DotSG {}
- data DotNode a = DotNode {
- nodeID :: a
- nodeAttributes :: Attributes
- data DotEdge a = DotEdge {
- edgeFromNodeID :: a
- edgeToNodeID :: a
- directedEdge :: Bool
- edgeAttributes :: Attributes
The overall representation of a graph in Dot format.
The internal representation of a graph in Dot form.
Constructors
| DotGraph | |
Fields
| |
Printing and parsing a DotGraph.
printDotGraph :: PrintDot a => DotGraph a -> StringSource
The actual Dot code for a DotGraph. Note that it is expected
that (this might not
be true the other way around due to un-parseable components).
parseDotGraph . printDotGraph == id
parseDotGraph :: ParseDot a => String -> DotGraph aSource
Parse a limited subset of the Dot language to form a DotGraph
(that is, the caveats listed in Data.GraphViz.Attributes aside,
Dot graphs are parsed if they match the layout of DotGraph).
Also removes any comments, etc. before parsing.
Functions acting on a DotGraph.
makeStrict :: DotGraph a -> DotGraph aSource
A strict graph disallows multiple edges.
graphNodes :: DotGraph a -> [DotNode a]Source
graphEdges :: DotGraph a -> [DotEdge a]Source
Reporting of errors in a DotGraph.
isValidGraph :: DotGraph a -> BoolSource
Check if all the Attributes are being used correctly.
graphErrors :: DotGraph a -> [DotError a]Source
Return detectable errors in the DotGraph.
Sub-components of a DotGraph.
data DotStatements a Source
Constructors
| DotStmts | |
Fields
| |
Instances
| Functor DotStatements | |
| Eq a => Eq (DotStatements a) | |
| Read a => Read (DotStatements a) | |
| Show a => Show (DotStatements a) | |
| ParseDot a => ParseDot (DotStatements a) | |
| PrintDot a => PrintDot (DotStatements a) |
data GlobalAttributes Source
Represents a list of top-level list of Attributes for the
entire graph/sub-graph. Note that GraphAttrs also applies to
DotSubGraphs.
Note that Dot allows a single Attribute to be listen on a line;
if this is the case then when parsing, the type of Attribute it
is determined and that type of GlobalAttribute is created.
Constructors
| GraphAttrs | |
Fields
| |
| NodeAttrs | |
Fields
| |
| EdgeAttrs | |
Fields
| |
data DotSubGraph a Source
Constructors
| DotSG | |
Fields
| |
Instances
| Functor DotSubGraph | |
| Eq a => Eq (DotSubGraph a) | |
| Read a => Read (DotSubGraph a) | |
| Show a => Show (DotSubGraph a) | |
| ParseDot a => ParseDot (DotSubGraph a) | |
| PrintDot a => PrintDot (DotSubGraph a) |
A node in DotGraph is either a singular node, or a cluster
containing nodes (or more clusters) within it.
At the moment, clusters are not parsed.
Constructors
| DotNode | |
Fields
| |
An edge in DotGraph.
Constructors
| DotEdge | |
Fields
| |