Maintainer  Ivan.Miljenovic@gmail.com 

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
GraphID
values forgraphID
andsubGraphID
, you should ensure that none of them have the same printed value as one of thenodeID
values to avoid any possible problems.  If you want any
GlobalAttributes
in aDotSubGraph
and want them to only apply to thatDotSubGraph
, then you must ensure it does indeed have a validGraphID
.  All
DotSubGraph
s with
must have uniqueisCluster
=True
subGraphID
values (well, only if you want them to be generated sensibly).  If eventually outputting to a format such as SVG, then you should
make sure that your
DotGraph
has agraphID
, 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.).  Also, whilst Graphviz allows you to mix the types used for nodes, this library requires/assumes that they are all the same type.

DotEdge
defines an edge(a, b)
(with an edge going froma
tob
); in Dot parlance the edge has a head ata
and a tail atb
. Care must be taken when using the relatedHead*
andTail*
Attribute
s. 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 > n3
means to create a directed edge fromn1
ton2
and fromn2
ton3
). These types of edge definitions are parseable; however, they are converted to singleton edges.  It is not yet possible to create or parse edges with subgraphs/clusters as one of the end points.
 When either creating a
DotGraph
by hand or parsing one, it is possible to specify that
, butdirectedGraph
= dDotEdge
values with
.directedEdge
=not
d  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. If you wish to be able to use an arbitrary ordering, you may wish to use Data.GraphViz.Types.Generalised.
 The parser will strip out comments and preprocessor lines, join together multiline statements and concatenate split strings together. However, preprocessing within HTMLlike labels is currently not supported.
 Graphviz allows a node to be "defined" twice (e.g. the actual
node definition, and then in a subgraph with extra global attributes
applied to it). This actually represents the same node, but when
parsing they will be considered as separate
DotNode
s (such thatgraphNodes
will return both "definitions"). The canonical form (seeprettyPrint
in Data.GraphViz) combines the "definitions" into one.
See Data.GraphViz.Attributes for more limitations.
 class (PrintDot (dg n), ParseDot (dg n)) => DotRepr dg n where
 getID :: dg n > Maybe GraphID
 graphIsDirected :: dg n > Bool
 graphIsStrict :: dg n > Bool
 makeStrict :: dg n > dg n
 setID :: GraphID > dg n > dg n
 graphStructureInformation :: dg n > (GlobalAttributes, ClusterLookup)
 nodeInformation :: Bool > dg n > NodeLookup n
 edgeInformation :: Bool > dg n > [DotEdge n]
 type ClusterLookup = Map (Maybe GraphID) ([Path], GlobalAttributes)
 type NodeLookup n = Map n (Path, Attributes)
 type Path = Seq (Maybe GraphID)
 graphNodes :: (DotRepr dg n, Ord n) => dg n > [DotNode n]
 graphEdges :: DotRepr dg n => dg n > [DotEdge n]
 printDotGraph :: DotRepr dg n => dg n > String
 parseDotGraph :: DotRepr dg n => String > dg n
 data DotGraph a = DotGraph {}
 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
Abstraction from the representation type
class (PrintDot (dg n), ParseDot (dg n)) => DotRepr dg n whereSource
This class is used to provide a common interface to different ways of representing a graph in Dot form.
getID :: dg n > Maybe GraphIDSource
Return the ID of the graph.
graphIsDirected :: dg n > BoolSource
Is this graph directed?
graphIsStrict :: dg n > BoolSource
Is this graph strict?
makeStrict :: dg n > dg nSource
A strict graph disallows multiple edges.
setID :: GraphID > dg n > dg nSource
Set the ID of the graph.
graphStructureInformation :: dg n > (GlobalAttributes, ClusterLookup)Source
Return information on all the clusters contained within this
DotRepr
, as well as the toplevel GraphAttrs
for the
overall graph.
nodeInformation :: Bool > dg n > NodeLookup nSource
Return information on the DotNode
s contained within this
DotRepr
. The Bool
parameter indicates if applicable
NodeAttrs
should be included.
edgeInformation :: Bool > dg n > [DotEdge n]Source
Helper types for looking up information within a DotRepr
.
type ClusterLookup = Map (Maybe GraphID) ([Path], GlobalAttributes)Source
The available information for each cluster; the [
denotes all locations where that particular cluster is located
(more than one location can indicate possible problems).
Path
]
type NodeLookup n = Map n (Path, Attributes)Source
The available information on each DotNode
(both explicit and implicit).
type Path = Seq (Maybe GraphID)Source
The path of clusters that must be traversed to reach this spot.
Obtaining the DotNode
s and DotEdges
.
graphNodes :: (DotRepr dg n, Ord n) => dg n > [DotNode n]Source
graphEdges :: DotRepr dg n => dg n > [DotEdge n]Source
Printing and parsing a DotRepr
.
printDotGraph :: DotRepr dg n => dg n > StringSource
The actual Dot code for an instance of DotRepr
. Note that it
is expected that
(this might not be true the other way around due to unparseable
components).
parseDotGraph
. printDotGraph
== id
parseDotGraph :: DotRepr dg n => String > dg nSource
Parse a limited subset of the Dot language to form an instance of
DotRepr
. Each instance may have its own limitations on what
may or may not be parseable Dot code.
Also removes any comments, etc. before parsing.
The overall representation of a graph in Dot format.
The internal representation of a graph in Dot form.
DotGraph  

Reporting of errors in a DotGraph
.
isValidGraph :: DotGraph a > BoolSource
Check if all the Attribute
s are being used correctly.
graphErrors :: DotGraph a > [DotError a]Source
Return detectable errors in the DotGraph
.
Subcomponents of a DotGraph
.
data DotStatements a Source
DotStmts  

Functor DotStatements  
Eq a => Eq (DotStatements a)  
Ord a => Ord (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 toplevel list of Attribute
s for the
entire graph/subgraph. Note that GraphAttrs
also applies to
DotSubGraph
s.
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.
data DotSubGraph a Source
DotSG  

Functor DotSubGraph  
Eq a => Eq (DotSubGraph a)  
Ord a => Ord (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
.
DotNode  

An edge in DotGraph
.
DotEdge  
