package catala
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=2615968670ac21b1d00386a9b04b3843
sha512=eff292fdd75012f26ce7b17020f5a8374eef37cd4dd6ba60338dfbe89fbcad3443d1b409e44c182b740da9f58dff7e76dcb8ddefe47f9b2b160666d1c6930143
doc/catala.catala_utils/Catala_utils/Graphs/JSON_Graph/argument-2-G/index.html
Parameter JSON_Graph.G
Graph structure
module V : Graph.Sig.VERTEX with type t = V.t
Vertices have type V.t
and are labeled with type V.label
(note that an implementation may identify the vertex with its label)
type vertex = V.t
module E : Graph.Sig.EDGE with type vertex = vertex
Edges have type E.t
and are labeled with type E.label
. src
(resp. dst
) returns the origin (resp. the destination) of a given edge.
type edge = E.t
Size functions
val is_empty : t -> bool
val nb_vertex : t -> int
val nb_edges : t -> int
Degree of a vertex
Membership functions
find_edge g v1 v2
returns the edge from v1
to v2
if it exists. Unspecified behaviour if g
has several edges from v1
to v2
.
find_all_edges g v1 v2
returns all the edges from v1
to v2
.
Successors and predecessors
You should better use iterators on successors/predecessors (see Section "Vertex iterators").
Labeled edges going from/to a vertex
Graph iterators
Iter on all edges of a graph. Edge label is ignored.
Fold on all edges of a graph. Edge label is ignored.
Map on all vertices of a graph.
The current implementation requires the supplied function to be injective. Said otherwise, map_vertex
cannot be used to contract a graph by mapping several vertices to the same vertex. To contract a graph, use instead create
, add_vertex
, and add_edge
.
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.
iter/fold on all successors/predecessors of a vertex.
iter/fold on all edges going from/to a vertex.