let rec mapToTreeNodes graphnodelist tree graph=
match graphnodelist with
x :: tail -> let outes = (DG.nodefoldoutedges graph (fun y a -> y::a) x [])
in let children_id = List.map (fun (_,t,_) -> t.id) outes
in mapToTreeNodes tail (addNewNode tree x children_id) graph
| _ -> tree