Maintainer | [email protected] |
---|
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
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. - 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. - Cannot create 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 - 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 Attribute
s 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) | |
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 top-level list of Attribute
s for the
entire graph/sub-graph. 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.
Constructors
GraphAttrs | |
Fields
| |
NodeAttrs | |
Fields
| |
EdgeAttrs | |
Fields
|
data DotSubGraph a Source
Constructors
DotSG | |
Fields
|
Instances
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
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
|