Frama-C API - Dotgraph
Helper for Printing Dot-graphs.
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.define dot
(fun a na ->
try
List.iter
(fun b -> G.edge dot na (N.get b) [])
(M.find a graph)
with Not_found -> ()) ;
(* Starts by emitting some roots, or all nodes *)
List.iter N.add 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 Attributes
val pp_attr : Stdlib.Format.formatter -> attr -> unitDot Output
val close : dot -> unitInvoke 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.
val printf : dot -> ('a, Stdlib.Format.formatter, unit, unit) Stdlib.format4 -> 'aLow-level routine to directly write material in the dot file
val println : dot -> ('a, Stdlib.Format.formatter, unit, unit) Stdlib.format4 -> 'aLow-level routine to directly write material with an end-of-line ("\n") in the dot file
val flush : dot -> unitFlushes the dot file buffer to disk.
Nodes and Edges
val pp_node : node Pretty_utils.formatterval pp_edge : (node * node) Pretty_utils.formattera -> b
Clustering
The continuation shall add the graph content in the dot file. Clustering is true by default
module Record : sig ... endComplex node layout. Smart constructors to create records.
Create a port to a node, and returns the associated pseudo-node so you can link an edge to it.
Define the node to be a record
val irecord : dot -> ?prefix:string -> ?id:node -> ?rounded:bool -> ?attr:attr list -> record -> nodeCreate a new node from a record (combines fresh and record)
Node Indexing
module type Map = sig ... endval push : dot -> (unit -> unit) -> unitRegister a continuation to be executed later.
val run : dot -> unitFlushes all pending continuations.
Decorator
A text buffer to compose labels and attributes. You can add text and attributes to the buffer, and finally flush it by calling attributes. A single `Label attribute is finally emitted with all the added text (if non-empty).
val bprintf : buffer -> ('a, Stdlib.Format.formatter, unit, unit) Stdlib.format4 -> 'aAdd text material to buffer label.
val add_char : buffer -> char -> unitval add_label : buffer -> string -> unitOnly add attributes with a true boolean flag
