package topological_sort

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
module type Node = sig ... end
module Edge : sig ... end
val sort : ?verbose:Base.Bool.t -> (module Node with type t = 'node) -> 'node Base.List.t -> 'node Edge.t Base.List.t -> 'node Base.List.t Base.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.

OCaml

Innovation. Community. Security.