Data.GraphViz.Types.Canonical

graphviz-2999.20.0.3: Bindings to Graphviz for graph visualisation.

Copyright | (c) Matthew Sackman Ivan Lazar Miljenovic
License | 3-Clause BSD-style
Maintainer | Ivan.Miljenovic@gmail.com
Safe Haskell | None
Language | Haskell2010

Data.GraphViz.Types.Canonical

Contents

- Sub-components of a `DotGraph`.
- Re-exported from `Data.GraphViz.Types`

Description

A canonical Dot graph requires that within each graph/sub-graph, the statements are in the following order:

- global attributes
- sub-graphs/clusters
- nodes
- edges

This Dot graph representation is ideally suited for converting other data structures to Dot form (especially with the help of `graphElemsToDot` from Data.GraphViz).

If you require arbitrary ordering of statements, then use Data.GraphViz.Types.Generalised.

The sample graph could be implemented (this is actually the result of calling `canonicalise` from Data.GraphViz.Algorithms on the generalised one) as:

    DotGraph { strictGraph = False
             , directedGraph = True
             , graphID = Just (Str "G")
             , graphStatements = DotStmts { attrStmts = []
                                          , subGraphs = [ DotSG { isCluster = True
                                                                , subGraphID = Just (Num (Int 0))
                                                                , subGraphStmts = DotStmts { attrStmts = [ GraphAttrs [ style filled
                                                                                                                      , color LightGray
                                                                                                                      , textLabel "process #1"]
                                                                                                         , NodeAttrs [style filled, color White]]
                                                                                           , subGraphs = []
                                                                                           , nodeStmts = [ DotNode "a0" []
                                                                                                         , DotNode "a1" []
                                                                                                         , DotNode "a2" []
                                                                                                         , DotNode "a3" []]
                                                                                           , edgeStmts = [ DotEdge "a0" "a1" []
                                                                                                         , DotEdge "a1" "a2" []
                                                                                                         , DotEdge "a2" "a3" []
                                                                                                         , DotEdge "a3" "a0" []]}}
                                                        , DotSG { isCluster = True
                                                                , subGraphID = Just (Num (Int 1))
                                                                , subGraphStmts = DotStmts { attrStmts = [ GraphAttrs [textLabel "process #2", color Blue]
                                                                                                         , NodeAttrs [style filled]]
                                                                                           , subGraphs = []
                                                                                           , nodeStmts = [ DotNode "b0" []
                                                                                                         , DotNode "b1" []
                                                                                                         , DotNode "b2" []
                                                                                                         , DotNode "b3" []]
                                                                                           , edgeStmts = [ DotEdge "b0" "b1" []
                                                                                                         , DotEdge "b1" "b2" []
                                                                                                         , DotEdge "b2" "b3" []]}}]
                                          , nodeStmts = [ DotNode "end" [shape MSquare]
                                                        , DotNode "start" [shape MDiamond]]
                                          , edgeStmts = [ DotEdge "start" "a0" []
                                                        , DotEdge "start" "b0" []
                                                        , DotEdge "a1" "b3" []
                                                        , DotEdge "b2" "a3" []
                                                        , DotEdge "a3" "end" []
                                                        , DotEdge "b3" "end" []]}}

Note that whilst the above graph represents the same Dot graph as specified in Data.GraphViz.Types.Generalised, etc., it may be drawn slightly differently by the various Graphviz tools.

Synopsis

- data DotGraph n = DotGraph {
  - strictGraph :: Bool
  - directedGraph :: Bool
  - graphID :: Maybe GraphID
  - graphStatements :: DotStatements n
  }
- data DotStatements n = DotStmts {
  - attrStmts :: [GlobalAttributes]
  - subGraphs :: [DotSubGraph n]
  - nodeStmts :: [DotNode n]
  - edgeStmts :: [DotEdge n]
  }
- data DotSubGraph n = DotSG {
  - isCluster :: Bool
  - subGraphID :: Maybe GraphID
  - subGraphStmts :: DotStatements n
  }
- data GraphID
  - = Str Text
  - | Num Number
- data GlobalAttributes
  - = GraphAttrs {
    - attrs :: Attributes
    }
  - | NodeAttrs {
    - attrs :: Attributes
    }
  - | EdgeAttrs {
    - attrs :: Attributes
    }
- data DotNode n = DotNode {
  - nodeID :: n
  - nodeAttributes :: Attributes
  }
- data DotEdge n = DotEdge {
  - fromNode :: n
  - toNode :: n
  - edgeAttributes :: Attributes
  }

# Documentation

data DotGraph n #

A Dot graph in canonical form.

Constructors

DotGraph |
Fields strictGraph :: Bool If `True`, no multiple edges are drawn. directedGraph :: Bool graphID :: Maybe GraphID graphStatements :: DotStatements n

Instances

Functor DotGraph # | Assumed to be an injective mapping function.
Instance details Defined in Data.GraphViz.Types.Canonical Methods fmap :: (a -> b) -> DotGraph a -> DotGraph b # (<$) :: a -> DotGraph b -> DotGraph a #
(Ord n, PrintDot n, ParseDot n) => PPDotRepr DotGraph n # |
Instance details Defined in Data.GraphViz.Types
(Ord n, ParseDot n) => ParseDotRepr DotGraph n # |
Instance details Defined in Data.GraphViz.Types
(Ord n, PrintDot n) => PrintDotRepr DotGraph n # |
Instance details Defined in Data.GraphViz.Types
Ord n => DotRepr DotGraph n # |
Instance details Defined in Data.GraphViz.Types Methods fromCanonical :: DotGraph n -> DotGraph n # getID :: DotGraph n -> Maybe GraphID # setID :: GraphID -> DotGraph n -> DotGraph n # graphIsDirected :: DotGraph n -> Bool # setIsDirected :: Bool -> DotGraph n -> DotGraph n # graphIsStrict :: DotGraph n -> Bool # setStrictness :: Bool -> DotGraph n -> DotGraph n # mapDotGraph :: DotRepr DotGraph n' => (n -> n') -> DotGraph n -> DotGraph n' # graphStructureInformation :: DotGraph n -> (GlobalAttributes, ClusterLookup) # nodeInformation :: Bool -> DotGraph n -> NodeLookup n # edgeInformation :: Bool -> DotGraph n -> [DotEdge n] # unAnonymise :: DotGraph n -> DotGraph n #
Ord n => FromGeneralisedDot DotGraph n # |
Instance details Defined in Data.GraphViz.Types.Generalised Methods fromGeneralised :: DotGraph0 n -> DotGraph n #
Eq n => Eq (DotGraph n) # |
Instance details Defined in Data.GraphViz.Types.Canonical Methods (==) :: DotGraph n -> DotGraph n -> Bool # (/=) :: DotGraph n -> DotGraph n -> Bool #
Ord n => Ord (DotGraph n) # |
Instance details Defined in Data.GraphViz.Types.Canonical Methods compare :: DotGraph n -> DotGraph n -> Ordering # (<) :: DotGraph n -> DotGraph n -> Bool # (<=) :: DotGraph n -> DotGraph n -> Bool # (>) :: DotGraph n -> DotGraph n -> Bool # (>=) :: DotGraph n -> DotGraph n -> Bool # max :: DotGraph n -> DotGraph n -> DotGraph n # min :: DotGraph n -> DotGraph n -> DotGraph n #
Read n => Read (DotGraph n) # |
Instance details Defined in Data.GraphViz.Types.Canonical Methods readsPrec :: Int -> ReadS (DotGraph n) # readList :: ReadS [DotGraph n] # readPrec :: ReadPrec (DotGraph n) # readListPrec :: ReadPrec [DotGraph n] #
Show n => Show (DotGraph n) # |
Instance details Defined in Data.GraphViz.Types.Canonical Methods showsPrec :: Int -> DotGraph n -> ShowS # show :: DotGraph n -> String # showList :: [DotGraph n] -> ShowS #
ParseDot n => ParseDot (DotGraph n) # |
Instance details Defined in Data.GraphViz.Types.Canonical Methods parseUnqt :: Parse (DotGraph n) # parse :: Parse (DotGraph n) # parseUnqtList :: Parse [DotGraph n] # parseList :: Parse [DotGraph n] #
PrintDot n => PrintDot (DotGraph n) # |
Instance details Defined in Data.GraphViz.Types.Canonical Methods unqtDot :: DotGraph n -> DotCode # toDot :: DotGraph n -> DotCode # unqtListToDot :: [DotGraph n] -> DotCode # listToDot :: [DotGraph n] -> DotCode #

# Sub-components of a `DotGraph`.

data DotStatements n #

Constructors

DotStmts |
Fields attrStmts :: [GlobalAttributes] subGraphs :: [DotSubGraph n] nodeStmts :: [DotNode n] edgeStmts :: [DotEdge n]

Instances

Functor DotStatements # |
Instance details Defined in Data.GraphViz.Types.Canonical Methods fmap :: (a -> b) -> DotStatements a -> DotStatements b # (<$) :: a -> DotStatements b -> DotStatements a #
Eq n => Eq (DotStatements n) # |
Instance details Defined in Data.GraphViz.Types.Canonical Methods (==) :: DotStatements n -> DotStatements n -> Bool # (/=) :: DotStatements n -> DotStatements n -> Bool #
Ord n => Ord (DotStatements n) # |
Instance details Defined in Data.GraphViz.Types.Canonical Methods compare :: DotStatements n -> DotStatements n -> Ordering # (<) :: DotStatements n -> DotStatements n -> Bool # (<=) :: DotStatements n -> DotStatements n -> Bool # (>) :: DotStatements n -> DotStatements n -> Bool # (>=) :: DotStatements n -> DotStatements n -> Bool # max :: DotStatements n -> DotStatements n -> DotStatements n # min :: DotStatements n -> DotStatements n -> DotStatements n #
Read n => Read (DotStatements n) # |
Instance details Defined in Data.GraphViz.Types.Canonical Methods readsPrec :: Int -> ReadS (DotStatements n) # readList :: ReadS [DotStatements n] # readPrec :: ReadPrec (DotStatements n) # readListPrec :: ReadPrec [DotStatements n] #
Show n => Show (DotStatements n) # |
Instance details Defined in Data.GraphViz.Types.Canonical Methods showsPrec :: Int -> DotStatements n -> ShowS # show :: DotStatements n -> String # showList :: [DotStatements n] -> ShowS #
ParseDot n => ParseDot (DotStatements n) # |
Instance details Defined in Data.GraphViz.Types.Canonical Methods parseUnqt :: Parse (DotStatements n) # parse :: Parse (DotStatements n) # parseUnqtList :: Parse [DotStatements n] # parseList :: Parse [DotStatements n] #
PrintDot n => PrintDot (DotStatements n) # |
Instance details Defined in Data.GraphViz.Types.Canonical Methods unqtDot :: DotStatements n -> DotCode # toDot :: DotStatements n -> DotCode # unqtListToDot :: [DotStatements n] -> DotCode # listToDot :: [DotStatements n] -> DotCode #

data DotSubGraph n #

Constructors

DotSG |
Fields isCluster :: Bool subGraphID :: Maybe GraphID subGraphStmts :: DotStatements n

Instances

Functor DotSubGraph # |
Instance details Defined in Data.GraphViz.Types.Canonical Methods fmap :: (a -> b) -> DotSubGraph a -> DotSubGraph b # (<$) :: a -> DotSubGraph b -> DotSubGraph a #
Eq n => Eq (DotSubGraph n) # |
Instance details Defined in Data.GraphViz.Types.Canonical Methods (==) :: DotSubGraph n -> DotSubGraph n -> Bool # (/=) :: DotSubGraph n -> DotSubGraph n -> Bool #
Ord n => Ord (DotSubGraph n) # |
Instance details Defined in Data.GraphViz.Types.Canonical Methods compare :: DotSubGraph n -> DotSubGraph n -> Ordering # (<) :: DotSubGraph n -> DotSubGraph n -> Bool # (<=) :: DotSubGraph n -> DotSubGraph n -> Bool # (>) :: DotSubGraph n -> DotSubGraph n -> Bool # (>=) :: DotSubGraph n -> DotSubGraph n -> Bool # max :: DotSubGraph n -> DotSubGraph n -> DotSubGraph n # min :: DotSubGraph n -> DotSubGraph n -> DotSubGraph n #
Read n => Read (DotSubGraph n) # |
Instance details Defined in Data.GraphViz.Types.Canonical Methods readsPrec :: Int -> ReadS (DotSubGraph n) # readList :: ReadS [DotSubGraph n] # readPrec :: ReadPrec (DotSubGraph n) # readListPrec :: ReadPrec [DotSubGraph n] #
Show n => Show (DotSubGraph n) # |
Instance details Defined in Data.GraphViz.Types.Canonical Methods showsPrec :: Int -> DotSubGraph n -> ShowS # show :: DotSubGraph n -> String # showList :: [DotSubGraph n] -> ShowS #
ParseDot n => ParseDot (DotSubGraph n) # |
Instance details Defined in Data.GraphViz.Types.Canonical Methods parseUnqt :: Parse (DotSubGraph n) # parse :: Parse (DotSubGraph n) # parseUnqtList :: Parse [DotSubGraph n] # parseList :: Parse [DotSubGraph n] #
PrintDot n => PrintDot (DotSubGraph n) # |
Instance details Defined in Data.GraphViz.Types.Canonical Methods unqtDot :: DotSubGraph n -> DotCode # toDot :: DotSubGraph n -> DotCode # unqtListToDot :: [DotSubGraph n] -> DotCode # listToDot :: [DotSubGraph n] -> DotCode #

# Re-exported from `Data.GraphViz.Types`

data GraphID #

A polymorphic type that covers all possible ID values allowed by Dot syntax. Note that whilst the `ParseDot` and `PrintDot` instances for `String` will properly take care of the special cases for numbers, they are treated differently here.

Constructors

Str Text |
Num Number |

Instances

Eq GraphID # |
Instance details Defined in Data.GraphViz.Types.Internal.Common Methods (==) :: GraphID -> GraphID -> Bool # (/=) :: GraphID -> GraphID -> Bool #
Ord GraphID # |
Instance details Defined in Data.GraphViz.Types.Internal.Common Methods compare :: GraphID -> GraphID -> Ordering # (<) :: GraphID -> GraphID -> Bool # (<=) :: GraphID -> GraphID -> Bool # (>) :: GraphID -> GraphID -> Bool # (>=) :: GraphID -> GraphID -> Bool # max :: GraphID -> GraphID -> GraphID # min :: GraphID -> GraphID -> GraphID #
Read GraphID # |
Instance details Defined in Data.GraphViz.Types.Internal.Common Methods readsPrec :: Int -> ReadS GraphID # readList :: ReadS [GraphID] # readPrec :: ReadPrec GraphID # readListPrec :: ReadPrec [GraphID] #
Show GraphID # |
Instance details Defined in Data.GraphViz.Types.Internal.Common Methods showsPrec :: Int -> GraphID -> ShowS # show :: GraphID -> String # showList :: [GraphID] -> ShowS #
ParseDot GraphID # |
Instance details Defined in Data.GraphViz.Types.Internal.Common Methods parseUnqt :: Parse GraphID # parse :: Parse GraphID # parseUnqtList :: Parse [GraphID] # parseList :: Parse [GraphID] #
PrintDot GraphID # |
Instance details Defined in Data.GraphViz.Types.Internal.Common Methods unqtDot :: GraphID -> DotCode # toDot :: GraphID -> DotCode # unqtListToDot :: [GraphID] -> DotCode # listToDot :: [GraphID] -> DotCode #

data GlobalAttributes #

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 listed 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 attrs :: Attributes
NodeAttrs |
Fields attrs :: Attributes
EdgeAttrs |
Fields attrs :: Attributes

Instances

Eq GlobalAttributes # |
Instance details Defined in Data.GraphViz.Types.Internal.Common Methods (==) :: GlobalAttributes -> GlobalAttributes -> Bool # (/=) :: GlobalAttributes -> GlobalAttributes -> Bool #
Ord GlobalAttributes # |
Instance details Defined in Data.GraphViz.Types.Internal.Common Methods compare :: GlobalAttributes -> GlobalAttributes -> Ordering # (<) :: GlobalAttributes -> GlobalAttributes -> Bool # (<=) :: GlobalAttributes -> GlobalAttributes -> Bool # (>) :: GlobalAttributes -> GlobalAttributes -> Bool # (>=) :: GlobalAttributes -> GlobalAttributes -> Bool # max :: GlobalAttributes -> GlobalAttributes -> GlobalAttributes # min :: GlobalAttributes -> GlobalAttributes -> GlobalAttributes #
Read GlobalAttributes # |
Instance details Defined in Data.GraphViz.Types.Internal.Common Methods readsPrec :: Int -> ReadS GlobalAttributes # readList :: ReadS [GlobalAttributes] # readPrec :: ReadPrec GlobalAttributes # readListPrec :: ReadPrec [GlobalAttributes] #
Show GlobalAttributes # |
Instance details Defined in Data.GraphViz.Types.Internal.Common Methods showsPrec :: Int -> GlobalAttributes -> ShowS # show :: GlobalAttributes -> String # showList :: [GlobalAttributes] -> ShowS #
ParseDot GlobalAttributes # |
Instance details Defined in Data.GraphViz.Types.Internal.Common Methods parseUnqt :: Parse GlobalAttributes # parse :: Parse GlobalAttributes # parseUnqtList :: Parse [GlobalAttributes] # parseList :: Parse [GlobalAttributes] #
PrintDot GlobalAttributes # |
Instance details Defined in Data.GraphViz.Types.Internal.Common Methods unqtDot :: GlobalAttributes -> DotCode # toDot :: GlobalAttributes -> DotCode # unqtListToDot :: [GlobalAttributes] -> DotCode # listToDot :: [GlobalAttributes] -> DotCode #

data DotNode n #

A node in `DotGraph`.

Constructors

DotNode |
Fields nodeID :: n nodeAttributes :: Attributes

Instances

Functor DotNode # |
Instance details Defined in Data.GraphViz.Types.Internal.Common Methods fmap :: (a -> b) -> DotNode a -> DotNode b # (<$) :: a -> DotNode b -> DotNode a #
Eq n => Eq (DotNode n) # |
Instance details Defined in Data.GraphViz.Types.Internal.Common Methods (==) :: DotNode n -> DotNode n -> Bool # (/=) :: DotNode n -> DotNode n -> Bool #
Ord n => Ord (DotNode n) # |
Instance details Defined in Data.GraphViz.Types.Internal.Common Methods compare :: DotNode n -> DotNode n -> Ordering # (<) :: DotNode n -> DotNode n -> Bool # (<=) :: DotNode n -> DotNode n -> Bool # (>) :: DotNode n -> DotNode n -> Bool # (>=) :: DotNode n -> DotNode n -> Bool # max :: DotNode n -> DotNode n -> DotNode n # min :: DotNode n -> DotNode n -> DotNode n #
Read n => Read (DotNode n) # |
Instance details Defined in Data.GraphViz.Types.Internal.Common Methods readsPrec :: Int -> ReadS (DotNode n) # readList :: ReadS [DotNode n] # readPrec :: ReadPrec (DotNode n) # readListPrec :: ReadPrec [DotNode n] #
Show n => Show (DotNode n) # |
Instance details Defined in Data.GraphViz.Types.Internal.Common Methods showsPrec :: Int -> DotNode n -> ShowS # show :: DotNode n -> String # showList :: [DotNode n] -> ShowS #
ParseDot n => ParseDot (DotNode n) # |
Instance details Defined in Data.GraphViz.Types.Internal.Common Methods parseUnqt :: Parse (DotNode n) # parse :: Parse (DotNode n) # parseUnqtList :: Parse [DotNode n] # parseList :: Parse [DotNode n] #
PrintDot n => PrintDot (DotNode n) # |
Instance details Defined in Data.GraphViz.Types.Internal.Common Methods unqtDot :: DotNode n -> DotCode # toDot :: DotNode n -> DotCode # unqtListToDot :: [DotNode n] -> DotCode # listToDot :: [DotNode n] -> DotCode #

data DotEdge n #

An edge in `DotGraph`.

Constructors

DotEdge |
Fields fromNode :: n toNode :: n edgeAttributes :: Attributes

Instances

Functor DotEdge # |
Instance details Defined in Data.GraphViz.Types.Internal.Common Methods fmap :: (a -> b) -> DotEdge a -> DotEdge b # (<$) :: a -> DotEdge b -> DotEdge a #
Eq n => Eq (DotEdge n) # |
Instance details Defined in Data.GraphViz.Types.Internal.Common Methods (==) :: DotEdge n -> DotEdge n -> Bool # (/=) :: DotEdge n -> DotEdge n -> Bool #
Ord n => Ord (DotEdge n) # |
Instance details Defined in Data.GraphViz.Types.Internal.Common Methods compare :: DotEdge n -> DotEdge n -> Ordering # (<) :: DotEdge n -> DotEdge n -> Bool # (<=) :: DotEdge n -> DotEdge n -> Bool # (>) :: DotEdge n -> DotEdge n -> Bool # (>=) :: DotEdge n -> DotEdge n -> Bool # max :: DotEdge n -> DotEdge n -> DotEdge n # min :: DotEdge n -> DotEdge n -> DotEdge n #
Read n => Read (DotEdge n) # |
Instance details Defined in Data.GraphViz.Types.Internal.Common Methods readsPrec :: Int -> ReadS (DotEdge n) # readList :: ReadS [DotEdge n] # readPrec :: ReadPrec (DotEdge n) # readListPrec :: ReadPrec [DotEdge n] #
Show n => Show (DotEdge n) # |
Instance details Defined in Data.GraphViz.Types.Internal.Common Methods showsPrec :: Int -> DotEdge n -> ShowS # show :: DotEdge n -> String # showList :: [DotEdge n] -> ShowS #
ParseDot n => ParseDot (DotEdge n) # |
Instance details Defined in Data.GraphViz.Types.Internal.Common Methods parseUnqt :: Parse (DotEdge n) # parse :: Parse (DotEdge n) # parseUnqtList :: Parse [DotEdge n] # parseList :: Parse [DotEdge n] #
PrintDot n => PrintDot (DotEdge n) # |
Instance details Defined in Data.GraphViz.Types.Internal.Common Methods unqtDot :: DotEdge n -> DotCode # toDot :: DotEdge n -> DotCode # unqtListToDot :: [DotEdge n] -> DotCode # listToDot :: [DotEdge n] -> DotCode #