Module Graph.Dfs

Depth-first search

val iter : ?pre:( V.t -> unit ) -> ?post:( V.t -> unit ) -> t -> unit

iter pre post g visits all nodes of g in depth-first search, applying pre to each visited node before its successors, and post after them. Each node is visited exactly once.

val prefix : ( V.t -> unit ) -> t -> unit

applies only a prefix function

val postfix : ( V.t -> unit ) -> t -> unit

applies only a postfix function

val fold : ( V.t -> 'a -> 'a ) -> 'a -> t -> 'a

Same thing, but for a single connected component

val iter_component : ?pre:( V.t -> unit ) -> ?post:( V.t -> unit ) -> t -> V.t -> unit
val prefix_component : ( V.t -> unit ) -> t -> V.t -> unit
val postfix_component : ( V.t -> unit ) -> t -> V.t -> unit
val fold_component : ( V.t -> 'a -> 'a ) -> 'a -> t -> V.t -> 'a
val has_cycle : t -> bool