1 (**************************************************************************)
5 (* François Pottier, INRIA Rocquencourt *)
6 (* Yann Régis-Gianas, PPS, Université Paris Diderot *)
8 (* Copyright 2005-2008 Institut National de Recherche en Informatique *)
9 (* et en Automatique. All rights reserved. This file is distributed *)
10 (* under the terms of the Q Public License version 1.0, with the change *)
11 (* described in file LICENSE. *)
13 (**************************************************************************)
17 (* ------------------------------------------------------------------------- *)
19 (* Type definitions. *)
22 float * float (* in inches *)
39 (* Both nodes and edges. *)
53 (* ------------------------------------------------------------------------- *)
57 let print_style = function
80 sprintf
", style = %s" style
82 (* ------------------------------------------------------------------------- *)
84 (* The graph printer. *)
90 val name
: vertex
-> string
92 val successors
: (?
style:style -> label
:string -> vertex
-> unit) -> vertex
-> unit
94 val iter
: (?
style:style -> label
:string -> vertex
-> unit) -> unit
101 ?
(orientation
= Landscape
)
102 ?
(rankdir
= LeftToRight
)
107 fprintf f
"%s G {\n" (if directed
then "digraph" else "graph");
108 Option.iter
(fun (hsize
, vsize
) ->
109 fprintf f
"size=\"%f, %f\";\n" hsize vsize
111 begin match orientation
with
113 fprintf f
"orientation = portrait;\n"
115 fprintf f
"orientation = landscape;\n"
117 begin match rankdir
with
119 fprintf f
"rankdir = LR;\n"
121 fprintf f
"rankdir = TB;\n"
123 begin match ratio
with
125 fprintf f
"ratio = compress;\n"
127 fprintf f
"ratio = fill;\n"
129 fprintf f
"ratio = auto;\n"
132 G.iter
(fun ?
style ~label vertex
->
133 fprintf f
"%s [ label=\"%s\"%s ] ;\n"
139 G.iter
(fun ?
style ~label source
->
140 G.successors
(fun ?
style ~label destination
->
141 fprintf f
"%s %s %s [ label=\"%s\"%s ] ;\n"
143 (if directed
then "->" else "--")