Module Data.GraphViz

A simple library for graph visualization with Graphviz. It provides a data structure to represent graphs and operations to visualize them.

There is a convenient operation viewDotGraph which visualizes a graph with the dotviewcommand specified in the rc file of the Curry system. Thus, the value of the dotviewcommand field in the rc file (e.g., ~/.pakcsrc in case of PAKCS) should be correctly defined. Here are some reasonable settings of this field:

dotviewcommand=dot -Tpdf > /tmp/dotxxx.pdf && xdg-open /tmp/dotxxx.pdf
dotviewcommand=neato -Tpdf > /tmp/dotxxx.pdf && xdg-open /tmp/dotxxx.pdf
dotviewcommand=circo -Tpdf > /tmp/dotxxx.pdf && xdg-open /tmp/dotxxx.pdf
dotviewcommand=fdp -Tpdf > /tmp/dotxxx.pdf && xdg-open /tmp/dotxxx.pdf

Author: Michael Hanus

Version: May 2023

Summary of exported operations:

dgraph :: String -> [Node] -> [Edge] -> DotGraph  Deterministic 
Constructs a directed graph from a name and a list of nodes and edges.
dgraphWithAttrs :: String -> [(String,String)] -> [Node] -> [Edge] -> DotGraph  Deterministic 
Constructs a directed graph from a name, a list of attributes, and lists of nodes and edges.
ugraph :: String -> [Node] -> [Edge] -> DotGraph  Deterministic 
Constructs an undirected graph from a name and a list of nodes and edges.
ugraphWithAttrs :: String -> [(String,String)] -> [Node] -> [Edge] -> DotGraph  Deterministic 
Constructs an undirected graph from a name, a list of attributes, and lists of nodes and edges.
showDotGraph :: DotGraph -> String  Deterministic 
Shows a Dot graph as a string of the DOT language.
showDotGraphWithAttrs :: String -> DotGraph -> String  Deterministic 
Deprecated.
viewDotGraph :: DotGraph -> IO ()  Deterministic 
Visualize a DOT graph with the dotviewcommand specified in the rc file of the Curry system.
getDotViewCmd :: IO String  Deterministic 
Read the command for viewing dot files from the rc file of the Curry system.
setDotViewCmd :: String -> IO ()  Deterministic 
Sets the command for viewing dot files in the rc file of the Curry system.

Exported datatypes:


DotGraph

A Dot graph consists of a name, a list of graph attributes, and lists of nodes and edges. It can be either directed (DGraph) or undirected (UGraph).

Constructors:


Node

A node of a dot graph consists of a name and a list of attributes for this node.

Constructors:

  • Node :: String -> [(String,String)] -> Node

Edge

An edge of a dot graph consists of the names of the source and target node and a list of attributes for this edge.

Constructors:

  • Edge :: String -> String -> [(String,String)] -> Edge

Exported operations:

dgraph :: String -> [Node] -> [Edge] -> DotGraph  Deterministic 

Constructs a directed graph from a name and a list of nodes and edges.

Further infos:
  • solution complete, i.e., able to compute all solutions

dgraphWithAttrs :: String -> [(String,String)] -> [Node] -> [Edge] -> DotGraph  Deterministic 

Constructs a directed graph from a name, a list of attributes, and lists of nodes and edges. The attributes are graph attributes of the DOT language, e.g., [("ordering","out"), ("fontsize","10")].

Further infos:
  • solution complete, i.e., able to compute all solutions

ugraph :: String -> [Node] -> [Edge] -> DotGraph  Deterministic 

Constructs an undirected graph from a name and a list of nodes and edges.

Further infos:
  • solution complete, i.e., able to compute all solutions

ugraphWithAttrs :: String -> [(String,String)] -> [Node] -> [Edge] -> DotGraph  Deterministic 

Constructs an undirected graph from a name, a list of attributes, and lists of nodes and edges. The attributes are graph attributes of the DOT language, e.g., [("ordering","out"), ("fontsize","10")].

Further infos:
  • solution complete, i.e., able to compute all solutions

showDotGraph :: DotGraph -> String  Deterministic 

Shows a Dot graph as a string of the DOT language.

showDotGraphWithAttrs :: String -> DotGraph -> String  Deterministic 

Deprecated. Use dgraphWithAttrs or ugraphWithAttrs to construct graphs with attributes.

viewDotGraph :: DotGraph -> IO ()  Deterministic 

Visualize a DOT graph with the dotviewcommand specified in the rc file of the Curry system.

getDotViewCmd :: IO String  Deterministic 

Read the command for viewing dot files from the rc file of the Curry system.

setDotViewCmd :: String -> IO ()  Deterministic 

Sets the command for viewing dot files in the rc file of the Curry system.