From 580b515a80013387fea56e41b03a579edac38f75 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 --- helm/software/components/metadata/metadataDeps.ml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/helm/software/components/metadata/metadataDeps.ml b/helm/software/components/metadata/metadataDeps.ml index 0e1dbb817..3247114a2 100644 --- a/helm/software/components/metadata/metadataDeps.ml +++ b/helm/software/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