From 55ae9c989557fbb879104962b0db50b19a9cfd2b Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Thu, 20 Jul 2006 15:02:52 +0000 Subject: [PATCH] avoid collapsing node that does not need to be, i.e.: - nodes with no outgoing edges - nodes which have not been expanded before --- components/metadata/metadataDeps.ml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/components/metadata/metadataDeps.ml b/components/metadata/metadataDeps.ml index 0e1dbb817..3247114a2 100644 --- a/components/metadata/metadataDeps.ml +++ b/components/metadata/metadataDeps.ml @@ -205,9 +205,16 @@ struct [], 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 = -- 2.39.2