The Topo module can be used to sort elements according to a
partial order.
module Topo: sig
type 'a partial_order
exception Cyclic
val create : unit -> 'a partial_order
create () creates an empty partial order
val add : 'a partial_order -> 'a -> unit
add t a adds the element a to the partial order t
val inf : 'a partial_order -> 'a -> 'a -> unit
inf t a b adds the relation a &inf; b to the partial order
t. It raises Cyclic is the partial order contains a cycle.
val less : 'a partial_order -> 'a -> 'a -> bool
less t a b returns true is a is inferior to b according to
the partial order t. It raises Cyclic is the partial order contains
a cycle.
val list : 'a partial_order -> 'a list -> 'a list
list t list sorts list according to the partial order t.
It raises Cyclic is the partial order contains a cycle.
val cycle : 'a partial_order -> 'a list
cycle t returns a list of elements which have a cyclic relation
in the partial order t
val ordered : 'a partial_order -> bool
ordered t returns true is the partial order t has no cycles
end
Go to the first, previous, next, last section, table of contents.