Yog.Traversal.Sort (YogEx v0.70.0)

Copy Markdown View Source

Topological sorting algorithms — Kahn's algorithm and lexicographic variant.

Summary

Functions

Performs a lexicographically smallest topological sort.

Performs a topological sort on a directed graph using Kahn's algorithm.

Functions

lexicographical_topological_sort(graph, compare_nodes)

@spec lexicographical_topological_sort(Yog.graph(), (term(), term() ->
                                                 :lt | :eq | :gt)) ::
  {:ok, [Yog.node_id()]} | {:error, :contains_cycle}

Performs a lexicographically smallest topological sort.

topological_sort(graph)

@spec topological_sort(Yog.graph()) ::
  {:ok, [Yog.node_id()]} | {:error, :contains_cycle}

Performs a topological sort on a directed graph using Kahn's algorithm.