summaryrefslogtreecommitdiff
path: root/prototype/hypergraph.rb
diff options
context:
space:
mode:
Diffstat (limited to 'prototype/hypergraph.rb')
-rw-r--r--prototype/hypergraph.rb16
1 files changed, 15 insertions, 1 deletions
diff --git a/prototype/hypergraph.rb b/prototype/hypergraph.rb
index fdaba5a..08d1a29 100644
--- a/prototype/hypergraph.rb
+++ b/prototype/hypergraph.rb
@@ -189,7 +189,21 @@ def HG::all_paths hypergraph, root
paths = new_paths
}
- return paths
+ seen = Set.new
+ paths.select { |p|
+ reachable = Set.new
+ mark_reachable p, p.last, reachable
+ key = reachable.map(&:object_id).sort
+ !seen.include?(key) && seen.add(key)
+ }
+end
+
+def HG::mark_reachable path, edge, used
+ used << edge
+ edge.tails.each { |t|
+ child = path.find { |e| e.head == t }
+ mark_reachable path, child, used if child && !used.include?(child)
+ }
end
def HG::derive path, cur, carry