DependencySequencer

class Object
trait Matchable
class Any

Value members

Concrete methods

def apply[A : GetParents](nodes: Set[A]): Seq[Set[A]]

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

  1. for given nodes, find all leaves, i.e. the those without parents (e.g. task dependencies)
  2. disregard all that have already been visited and add to the results sequence
  3. repeat for the remainder of nodes see https://en.wikipedia.org/wiki/Topological_sorting#Kahn%27s_algorithm