DependencySequencer
object DependencySequencer
Value members
Concrete methods
Find the sequence of dependencies a set of nodes in a directed acyclic graph (DAG). Sample use case: concurrent task processing: given a set of tasks, determine which ones can be executed in parallel, and which ones need to run in sequence.
Find the sequence of dependencies a set of nodes in a directed acyclic graph (DAG). Sample use case: concurrent task processing: given a set of tasks, determine which ones can be executed in parallel, and which ones need to run in sequence.
- Throws:
- java.lang.AssertionError
if given nodes have cyclic dependencies Algorithm: variant of Kahn's algorithm for topological sort
- for given nodes, find all leaves, i.e. the those without parents (e.g. task dependencies)
- disregard all that have already been visited and add to the results sequence
- repeat for the remainder of nodes see https://en.wikipedia.org/wiki/Topological_sorting#Kahn%27s_algorithm