Object_graph.Make
Build a graph.
module Contents_key : Type.S
module Commit_key : Type.S
Directed graph
include Graph.Sig.I
with type V.t =
[ `Contents of Contents_key.t
| `Node of Node_key.t
| `Commit of Commit_key.t
| `Branch of Branch.t ]
module E : sig ... end
type edge = E.t
val is_empty : t -> bool
val nb_vertex : t -> int
val nb_edges : t -> int
val create : ?size:int -> unit -> t
val clear : t -> unit
Basic operations.
include Graph.Oper.S with type g := t
module Topological : sig ... end
Topological traversal
val closure :
?depth:int ->
pred:(vertex -> vertex list) ->
min:vertex list ->
max:vertex list ->
unit ->
t
closure depth pred min max ()
creates the transitive closure graph of max
using the predecessor relation pred
. The graph is bounded by the min
nodes and by depth
.
Note: Both min
and max
are subsets of n
.
val iter :
?cache_size:int ->
?depth:int ->
pred:(vertex -> vertex list) ->
min:vertex list ->
max:vertex list ->
node:(vertex -> unit) ->
?edge:(vertex -> vertex -> unit) ->
skip:(vertex -> bool) ->
rev:bool ->
unit ->
unit
iter depth min max node edge skip rev ()
iterates in topological order over the closure graph starting with the max
nodes and bounded by the min
nodes and by depth
.
It applies three functions while traversing the graph: node
on the nodes; edge n predecessor_of_n
on the directed edges and skip n
to not include a node n
, its predecessors and the outgoing edges of n
.
If rev
is true (the default) then the graph is traversed in the reverse order: node n
is applied only after it was applied on all its predecessors; edge n p
is applied after node n
. Note that edge n p
is applied even if p
is skipped.
cache_size
is the size of the LRU cache used to store nodes already seen. If None
(by default) every traversed nodes is stored (and thus no entries are never removed from the LRU).
val breadth_first_traversal :
?cache_size:int ->
pred:(vertex -> vertex list) ->
max:vertex list ->
node:(vertex -> unit) ->
unit ->
unit
breadth_first_traversal ?cache_size pred max node ()
traverses the closure graph in breadth-first order starting with the max
nodes. It applies node
on the nodes of the graph while traversing it.
val output :
Stdlib.Format.formatter ->
(vertex * Graph.Graphviz.DotAttributes.vertex list) list ->
(vertex * Graph.Graphviz.DotAttributes.edge list * vertex) list ->
string ->
unit
output ppf vertex edges name
create aand dumps the graph contents on ppf
. The graph is defined by its vertex
and edges
. name
is the name of the output graph.