Module Document.Graph

Graph Builder

A convenient module for building simple graphs and turning them into Graphviz code.

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
val set_graph_name : string -> event
val n : ?⁠lbl:string -> string -> event
val e : ?⁠lbl:string -> string -> string -> event
val to_doc : ?⁠a:attributes -> t -> doc