Module Blocks.Graph
Implementation of undirected graphs from implementation of directed graphs.
Parameters
G : sig ... end
Signature
include G
include Graph.Sig.G
module V : Graph.Sig.VERTEXVertices have type
V.tand are labeled with typeV.label(note that an implementation may identify the vertex with its label)
type vertex= V.t
module E : Graph.Sig.EDGE with type vertex = vertexEdges have type
E.tand are labeled with typeE.label.src(resp.dst) returns the origin (resp. the destination) of a given edge.
type edge= E.t
Size functions
Membership functions
val mem_vertex : t -> vertex -> boolval mem_edge : t -> vertex -> vertex -> boolval mem_edge_e : t -> edge -> boolval find_edge : t -> vertex -> vertex -> edgefind_edge g v1 v2returns the edge fromv1tov2if it exists. Unspecified behaviour ifghas several edges fromv1tov2.- raises Not_found
if no such edge exists.
Successors and predecessors
You should better use iterators on successors/predecessors (see Section "Vertex iterators").
val succ : t -> vertex -> vertex listsucc g vreturns the successors ofving.- raises Invalid_argument
if
vis not ing.
val pred : t -> vertex -> vertex listpred g vreturns the predecessors ofving.- raises Invalid_argument
if
vis not ing.
Graph iterators
val iter_edges : (vertex -> vertex -> unit) -> t -> unitIter on all edges of a graph. Edge label is ignored.
Vertex iterators
Each iterator iterator f v g iters f to the successors/predecessors of v in the graph g and raises Invalid_argument if v is not in g. It is the same for functions fold_* which use an additional accumulator.
<b>Time complexity for ocamlgraph implementations:</b> operations on successors are in O(1) amortized for imperative graphs and in O(ln(|V|)) for persistent graphs while operations on predecessors are in O(max(|V|,|E|)) for imperative graphs and in O(max(|V|,|E|)*ln|V|) for persistent graphs.
val is_directed : boolval iter_edges : (vertex -> vertex -> unit) -> t -> unitval fold_edges : (vertex -> vertex -> 'a -> 'a) -> t -> 'a -> 'aval iter_edges_e : (edge -> unit) -> t -> unitval fold_edges_e : (edge -> 'a -> 'a) -> t -> 'a -> 'aval nb_edges : t -> intval pred : t -> vertex -> vertex listval in_degree : t -> vertex -> intval iter_pred : (vertex -> unit) -> t -> vertex -> unitval fold_pred : (vertex -> 'a -> 'a) -> t -> vertex -> 'a -> 'aval pred_e : t -> vertex -> edge listval iter_pred_e : (edge -> unit) -> t -> vertex -> unitval fold_pred_e : (edge -> 'a -> 'a) -> t -> vertex -> 'a -> 'a