X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Fcomponents%2Fextlib%2FgraphvizPp.ml;h=46432883744ad7c68406be2d040dbe40134f25ce;hb=0c302a9fda708e5019e48d14c5419a8a65190745;hp=4804699e0a7ef048dae9851641411e7e768be6e5;hpb=22df969cb0629a8d6ea09534386279807ff02f1c;p=helm.git diff --git a/helm/software/components/extlib/graphvizPp.ml b/helm/software/components/extlib/graphvizPp.ml index 4804699e0..464328837 100644 --- a/helm/software/components/extlib/graphvizPp.ml +++ b/helm/software/components/extlib/graphvizPp.ml @@ -30,6 +30,7 @@ type attribute = string * string (* pair *) module type GraphvizFormatter = sig val header: + ?graph_type:string -> ?name:string -> ?graph_attrs:(attribute list) -> ?node_attrs:(attribute list) -> ?edge_attrs:(attribute list) -> Format.formatter -> @@ -48,15 +49,21 @@ module Dot = struct let attribute fmt (k, v) = fprintf fmt "@[%s=@,\"%s\",@]" k v let attributes attrs fmt = List.iter (attribute fmt) attrs + let quote_string quote s = if quote then "\"" ^s ^ "\"" else s let node name ~quote ?(attrs = []) fmt = - let quote_string = if quote then "\"" else "" in - fprintf fmt "@[%s%s%s@ [" quote_string name quote_string; + fprintf fmt "@[%s@ [" (quote_string quote name); attributes attrs fmt; fprintf fmt "];@]@," - let header ?(name = "g") ?(graph_attrs = []) ?node_attrs ?edge_attrs fmt = - fprintf fmt "@[strict digraph %s {@," name; + let edge ~quote name1 name2 ?(attrs = []) fmt = + fprintf fmt "@[%s ->@ %s@ [" + (quote_string quote name1) (quote_string quote name2); + attributes attrs fmt; + fprintf fmt "];@]@," + + let header ?(graph_type = "digraph") ?(name = "g") ?(graph_attrs = []) ?node_attrs ?edge_attrs fmt = + fprintf fmt "@[%s %s {@," graph_type name; List.iter (fun (k, v) -> fprintf fmt "@[%s=@,%s;@]@," k v) graph_attrs; (match node_attrs with @@ -67,10 +74,7 @@ module Dot = | None -> ()) let node = node ~quote:true - let edge name1 name2 ?(attrs = []) fmt = - fprintf fmt "@[\"%s\" ->@ \"%s\"@ [" name1 name2; - attributes attrs fmt; - fprintf fmt "];@]@," + let edge = edge ~quote:true let raw s fmt = pp_print_string fmt s let trailer fmt = fprintf fmt "@,}@]%!" end