let graph_from_tree tree =
let rec add_nodes nodelist graph =
match nodelist with
x::tail -> add_nodes tail (DG.addnode x graph)
| _ -> graph
in
let rec add_edges edgelist graph =
match edgelist with
x::tail -> add_edges tail (DG.addedge x graph)
| _ -> graph
in let nodes_added = add_nodes (IdtMap.fold (fun _ n nlist -> n.node::nlist) tree.treeNodes [] ) DG.empty
in add_edges (IdtMap.fold (fun _ e elist -> e.edge::elist) tree.treeEdges []) nodes_added