mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Fix transitive closure bug.
This commit is contained in:
parent
faa4bc17ce
commit
f9ecc7653c
1 changed files with 3 additions and 2 deletions
|
@ -68,11 +68,12 @@ class DynamicGraph<T> {
|
|||
|
||||
fun <T> transitiveClosureGraph(root: T, childrenFor: (T) -> List<T>, seen: HashSet<T> = hashSetOf()) : Node<T> {
|
||||
val children = arrayListOf<Node<T>>()
|
||||
println("TRANSITIVE CLOSURE FOR " + root)
|
||||
childrenFor(root).forEach { child ->
|
||||
if (! seen.contains(child)) {
|
||||
val c = transitiveClosureGraph(child, childrenFor)
|
||||
children.add(c)
|
||||
seen.add(child)
|
||||
val c = transitiveClosureGraph(child, childrenFor, seen)
|
||||
children.add(c)
|
||||
}
|
||||
}
|
||||
return Node(root, children)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue