Commit ba5e49bc authored by Bruno Guillaume's avatar Bruno Guillaume

use to_dot function defined in libcaml-conll

parent 928bf589
......@@ -808,56 +808,6 @@ module G_graph = struct
bprintf buff "} \n";
Buffer.contents buff
(* -------------------------------------------------------------------------------- *)
let to_dot ?domain ?main_feat ?(deco=G_deco.empty) graph =
let buff = Buffer.create 32 in
bprintf buff "digraph G {\n";
(* bprintf buff " rankdir=LR;\n"; *)
(* bprintf buff " node [shape=none];\n"; *)
(* nodes *)
Gid_map.iter
(fun id node ->
let decorated_feat =
try List.assoc id deco.G_deco.nodes
with Not_found -> ("",[]) in
bprintf buff " N_%s [label=<%s>, color=%s]\n"
(Gid.to_string id)
(G_fs.to_dot ~decorated_feat ?main_feat (G_node.get_fs node))
(* TODO: add bgcolor in dot output *)
(if List.mem_assoc id deco.G_deco.nodes then "red" else "black")
) graph.map;
(* edges *)
Gid_map.iter
(fun id node ->
Massoc_gid.iter
(fun tar g_edge ->
let deco = List.mem (id,g_edge,tar) deco.G_deco.edges in
if g_edge = G_edge.sub
then bprintf buff " N_%s -> N_%s [dir=none];\n" (Gid.to_string id) (Gid.to_string tar)
else bprintf buff " N_%s -> N_%s%s;\n" (Gid.to_string id) (Gid.to_string tar) (G_edge.to_dot ?domain ~deco g_edge)
) (G_node.get_next node)
) graph.map;
Gid_map.iter
(fun id node ->
begin
match G_node.get_succ node with
| Some s when !Global.debug ->
bprintf buff " N_%s -> N_%s [label=\"SUCC\", style=dotted, fontcolor=lightblue, color=lightblue]; {rank=same; N_%s; N_%s };\n"
(Gid.to_string id) (Gid.to_string s) (Gid.to_string id) (Gid.to_string s)
(* | Some s ->
bprintf buff " N_%s -> N_%s [style=invis]; {rank=same; N_%s; N_%s };\n"
(Gid.to_string id) (Gid.to_string s) (Gid.to_string id) (Gid.to_string s) *)
| _ -> ()
end
) graph.map;
bprintf buff "}\n";
Buffer.contents buff
(* -------------------------------------------------------------------------------- *)
let list_num test =
let rec loop n = function
......@@ -951,4 +901,8 @@ module G_graph = struct
let to_conll_string ?domain graph =
let conll = to_conll ?domain graph in
Conll.to_string (Conll.normalize_multiwords conll)
let to_dot ?domain ?main_feat ?(deco=G_deco.empty) graph =
let conll = to_conll ?domain graph in
Conll.to_dot conll
end (* module G_graph *)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment