Module Document.Graph
Graph Builder
A convenient module for building simple graphs and turning them into Graphviz code.
- Use
Graph.e ?lbl source_name destination_name
to describe an edge of the graph (with an optional label). - Use
Graph.n ?lbl node_name
to describe a node of the graph (with an optional label). Note that nodes that appear in at least one edge are not required to be specified withn
. - Use
Graph.set_graph_name s
(at most once) to give a name to the graph.
Example:
type g = { edges: (int * int) list; }
#program;;
let g_to_doc g =
let module D = Document in
D.Graph.(to_doc @@ List.map (fun (a,b) -> e (Int.to_string a) (Int.to_string b)) g.edges)
;;
#install_doc g_to_doc;;
{edges=[1,2; 3,4; 1,4; 2,10; 10,1; 3,2; 4,10] };;
type event
= private
|
Set_graph_name of string
|
Node of
{
name : string;
label : string;
}
|
Edge of
{
src : string;
target : string;
label : string;
}
type t
= event list