Skip to content

Commit

Permalink
#39: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
micHar committed Nov 12, 2021
1 parent 71332e4 commit 269cba9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,9 @@ internal class Graph<E, D>(
}

while (!queue.isEmpty()) {
println("Queue: ${queue.map { "${it.descriptor}" }}")
val vertex = queue.remove()
orderedList.add(vertex)
visitedNodes++
println("${vertex.descriptor} has incoming ${adjacencyMap[vertex]!!.map { it.descriptor }}")
adjacencyMap[vertex]!!.forEach {
it.inDegree--
if (it.inDegree == 0) queue.add(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class Processor : AbstractProcessor() {
generatedInterfaces = generatedInterfaces,
targetDir = kaptGeneratedDir
)
println("Generated: ${generatedInterface.name} from $typeName")
generatedInterfaces[typeName] = generatedInterface
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.futuremind.koru.processor
import com.futuremind.koru.processor.InheritanceSortTest.Ver.*
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test
import java.lang.IllegalArgumentException

internal class InheritanceSortTest {

Expand Down Expand Up @@ -60,6 +61,24 @@ internal class InheritanceSortTest {

}

@Test
fun `should throw on cyclic graph`() {
val graph = Graph(listOf(a, b))
graph.addEdge(a, b)
graph.addEdge(b, a)
assertThrows(IllegalArgumentException::class.java) { graph.topologicalOrder() }
}

@Test
fun `should throw on cyclic graph (larger)`() {
val graph = Graph(listOf(a, b, c, d))
graph.addEdge(a, b)
graph.addEdge(b, c)
graph.addEdge(c, d)
graph.addEdge(d, a)
assertThrows(IllegalArgumentException::class.java) { graph.topologicalOrder() }
}

private fun test(
graph: Graph<Ver, Ver>,
expectedSorted: List<Vertex<Ver, Ver>>
Expand Down

0 comments on commit 269cba9

Please sign in to comment.