com.autonomousapps.graph.Topological.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dependency-analysis-gradle-plugin Show documentation
Show all versions of dependency-analysis-gradle-plugin Show documentation
Analyzes dependency usage in Android and JVM projects
package com.autonomousapps.graph
/**
* Finds the topological order of DAG `graph`. We know it has one, because it is a DAG.
*
* @param graph the DAG.
*/
internal class Topological(
private val graph: DependencyGraph
) {
private val order: Iterable
init {
val dfs = DepthFirstOrder(graph)
order = dfs.reversePost()
}
/**
* Returns a topological order for the digraph.
*
* @return a topological order of the nodes (as an iterable).
*/
fun order(): Iterable = order
}