Skip to content

Commit

Permalink
chore: fix typo in the DependencyGraph implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
dzikoysk committed Jul 27, 2024
1 parent 0d19abc commit 22dbb9b
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ fun toFlattenedDependencyGraph(declarations: Map<String, List<String>>): List<St
val node = nodesWithNoIncomingEdges.pop()
topologicalOrdering.add(node)

declarations[node]!!.forEach { neighbor ->
if (indegrees.compute(neighbor) { _, value -> (value ?: 1) - 1 } == 0) {
nodesWithNoIncomingEdges.push(neighbor)
declarations[node]!!.forEach { neighbour ->
if (indegrees.compute(neighbour) { _, value -> (value ?: 1) - 1 } == 0) {
nodesWithNoIncomingEdges.push(neighbour)
}
}
}
Expand All @@ -61,10 +61,10 @@ fun toFlattenedDependencyGraph(declarations: Map<String, List<String>>): List<St
private fun deepSearch(declarations: Map<String, List<String>>, track: Set<String>, current: String): List<String>? =
declarations[current]!!.asSequence()
.map { dependency ->
if (track.contains(dependency))
track.toMutableList().also { it.add(dependency) }
else
deepSearch(declarations, track.toMutableSet().also { it.add(dependency) }, dependency)
when {
track.contains(dependency) -> track.toMutableList().also { it.add(dependency) }
else -> deepSearch(declarations, track.toMutableSet().also { it.add(dependency) }, dependency)
}
}
.filterNotNull()
.firstOrNull()

0 comments on commit 22dbb9b

Please sign in to comment.