module Dotgraph:sig
..end
This module provides smart-constructors for constructing Dot input
files. Basically, a dot
object is a buffer to a <file.dot>
on
disk where smart constructors write Dot statements.
Once the <file.dot>
has been created, it is possible to layout it
by running the dot
command with various engines.
Typically, let say you have a graph with nodes of type
M.elt
with M : Map.S
and assumes the graph is stored
as a map graph : M.elt list M.t
with roots : M.elt list
then you can use:
let module G = Dotgraph in
let module N = G.Node(M) in
begin
let dot = G.open_dot ~name:"mygraph" () in
(* For each generated node, declare it and link to its children. *)
N.push dot
(fun a ->
let na = N.inode dot a in
try
List.iter
(fun b -> G.link dot na (N.get b))
(M.find a graph)
with Not_found -> ()) ;
(* Starts by emitting roots *)
List.iter
(fun r -> ignore (N.get r))
roots ;
(* Proceeds to the traversal *)
G.pop_all dot ;
(* You may then complete your graph
with other decorations after the traversal... *)
G.close dot ;
(* Now call the layout engine, if installed. *)
G.layout dot ~format:"pdf" () ;
end
typeattr =
[ `ArrowBack
| `ArrowBoth
| `ArrowForward
| `ArrowHead of string
| `ArrowTail of string
| `Attr of string * string
| `Box
| `Circle
| `Color of string
| `Dotted
| `Fillcolor of string
| `Filled
| `LR
| `Label of string
| `Oval
| `Point
| `Shape of string
| `Style of string
| `TB ]
val pp_attr : Format.formatter -> attr -> unit
type
dot
dot
file with a graph environment (nodes, edges, etc.)val open_dot : ?name:string ->
?attr:attr list -> ?file:string -> unit -> dot
val close : dot -> unit
val is_dot_installed : unit -> bool
val layout : ?force:bool ->
?target:string -> ?engine:string -> ?output:string -> dot -> string
dot
command (if installed) with specified target and engine.
Defaults are ~force:false
, ~target:"pdf"
, ~engine:"dot"
.
The dot
buffer must be closed before being laid out, although you can
invoke several layouts.
Output is stored in ~output
or in a filename derived from the one of dot
.
The function returns the generated output file.
Raises Invalid_argument
if dot
buffer is not closed, or when dot
command fails and ~force:true
(not by default).
val printf : dot -> ('a, Format.formatter, unit, unit) Pervasives.format4 -> 'a
dot
fileval println : dot -> ('a, Format.formatter, unit, unit) Pervasives.format4 -> 'a
"\n"
)
in the dot
fileval flush : dot -> unit
dot
file buffer to disk.type
node
val node_default : dot -> attr list -> unit
val edge_default : dot -> attr list -> unit
val fresh : ?prefix:string -> dot -> node
val pp_node : node Pretty_utils.formatter
val pp_edge : (node * node) Pretty_utils.formatter
a -> b
val node : dot -> node -> attr list -> unit
val edge : dot -> node -> node -> attr list -> unit
val link : dot -> node list -> attr list -> unit
val inode : dot ->
?prefix:string -> ?id:node -> attr list -> node
fresh
and node
val rank : dot -> node list -> unit
val subgraph : dot -> ?cluster:bool -> attr list -> (unit -> unit) -> unit
dot
file.
Clustering is true by defaulttyperecord =
[ `Empty
| `Hbox of record list
| `Label of string
| `Port of string * link list * string
| `Vbox of record list ]
typelink =
string * attr list * node
module Record:sig
..end
val port : node -> string -> node
val record : dot ->
node ->
?rounded:bool -> ?attr:attr list -> record -> unit
val irecord : dot ->
?prefix:string ->
?id:node ->
?rounded:bool -> ?attr:attr list -> record -> node
fresh
and record
)module type Map =sig
..end
module Node:
val push : dot -> (unit -> unit) -> unit
val pop_all : dot -> unit
type
buffer
attributes
.
A single `Label
attribute is finally emitted with
all the added text (if non-empty).val buffer : attr list -> buffer
val bprintf : buffer ->
('a, Format.formatter, unit, unit) Pervasives.format4 -> 'a
val add_char : buffer -> char -> unit
val add_label : buffer -> string -> unit
val add_attr : buffer -> attr list -> unit
val add_options : buffer -> (bool * attr list) list -> unit
true
boolean flagval attributes : buffer -> attr list
val decorate : attr list -> (bool * attr list) list -> attr list