[], 0
let collapse uri (adjlist, _root, f, _invert) =
+ try
+ let neighbs = UriTbl.find adjlist uri in
+ if Lazy.lazy_is_val neighbs.adjacency then
+ (* do not collapse already collapsed nodes *)
+ if Lazy.force neighbs.adjacency <> [] then
+ (* do not collapse nodes with no outgoing edges *)
+ UriTbl.replace adjlist uri { adjacency = lazy (f uri); shown = 0 }
+ with Not_found ->
(* do not add a collapsed node if it was not part of the graph *)
- if UriTbl.mem adjlist uri then
- UriTbl.replace adjlist uri { adjacency = lazy (f uri); shown = 0 }
+ ()
let graph_of_fun ?(invert = false) f ~dbd uri =
let f ~dbd uri =