Module Topological_sort

include Topological_sort__.Topological_sort_intf.Topological_sort
module Edge : sig ... end
val sort : ?verbose:bool ‑> (module Node with type t = 'node) ‑> 'node list ‑> 'node Edge.t list ‑> 'node list Core_kernel.Or_error.t

sort (module Node) nodes edges returns a list of nodes output satisfying:

  • every node that appears in nodes or edges occurs once in output.
  • if { from; to_ } is in edges, then from occurs before to_ in output.
  • nodes that have no incoming or outgoing edges appear sorted at the end of output.

sort returns Error if there is a cycle.