package topological_sort
Module Topological_sort
module type Node = sig ... endmodule Edge : sig ... endval 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.tsort (module Node) nodes edges returns a list of nodes output satisfying:
- every node that appears in
nodesoredgesoccurs once inoutput. - if
{ from; to_ }is inedges, thenfromoccurs beforeto_inoutput. - nodes that have no incoming or outgoing edges appear sorted at the end of
output.
sort returns Error if there is a cycle.