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
module What : sig ... end
val sort : ?verbose:Topological_sort__.Import.Bool.t -> (module Node with type t = 'node) -> what:What.t -> nodes:'node Topological_sort__.Import.List.t -> edges:'node Edge.t Topological_sort__.Import.List.t -> 'node Topological_sort__.Import.List.t Topological_sort__.Import.Or_error.t

sort (module Nodes) ~what ~nodes ~edges returns a list of nodes output satisfying:

  • output contains one occurrence of every node in nodes when what = Nodes, or one occurrence of every node in nodes and edges when what = Nodes_and_edge_endpoints.
  • 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.

val sort_or_cycle : ?verbose:Topological_sort__.Import.Bool.t -> (module Node with type t = 'node) -> what:What.t -> nodes:'node Topological_sort__.Import.List.t -> edges:'node Edge.t Topological_sort__.Import.List.t -> ('node Topological_sort__.Import.List.t, [ `Cycle of 'node Topological_sort__.Import.List.t ]) Topological_sort__.Import.Result.t

Same as sort, but returns the cycle if there is one.

OCaml

Innovation. Community. Security.