package topological_sort
Module Topological_sortSource
Controls the order in which we begin traversing nodes as entry points into the graph. The earliest nodes with finished traversals are returned last.
Source
val sort :
?traversal_order:Traversal_order.t ->
?verbose:Base.Bool.t ->
?verify:Base.Bool.t ->
(module Node with type t = 'node) ->
what:What.t ->
nodes:'node Base.List.t ->
edges:'node Edge.t Base.List.t ->
'node Base.List.t Base.Or_error.tsort (module Nodes) ~what ~nodes ~edges returns a list of nodes output satisfying:
outputcontains one occurrence of every node innodeswhenwhat = Nodes, or one occurrence of every node innodesandedgeswhenwhat = Nodes_and_edge_endpoints.- if
{ from; to_ }is inedges, thenfromoccurs beforeto_inoutput.
sort returns Error if there is a cycle.
traversal_order determines the order in which we processing nodes as entry points into the graph.
verify checks that the sorted output or generated cycle is indeed correct.
Source
val sort_or_cycle :
?traversal_order:Traversal_order.t ->
?verbose:Base.Bool.t ->
?verify:Base.Bool.t ->
(module Node with type t = 'node) ->
what:What.t ->
nodes:'node Base.List.t ->
edges:'node Edge.t Base.List.t ->
('node Base.List.t, [ `Cycle of 'node Base.List.t ]) Base.Result.tSame as sort, but returns the cycle if there is one.