1
0
Fork 0
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:
Cedric Beust 2016-08-02 23:14:15 -08:00
parent faa4bc17ce
commit f9ecc7653c

View file

@ -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)