Page
Library
Module
Module type
Parameter
Class
Class type
Source
Incremental_cycles.Raw_graphSourceSignature for the graph data structure on which the algorithm operates. It is the input signature of the Make functor.
This corresponds to a standard imperative directed graph structure.
Additionally, extra meta-data is associated to each node, to hold internal data of the cycle detection algorithm. The meta-data is written and accessed by the algorithm through the corresponding set_* and get_* functions; it must not be modified otherwise.
The standard graph operations provided by Raw_graph are:
The extra meta-data that Raw_graph must provide is:
No particular assumption should be made by the implementor of Raw_graph about the contents of these fields.
NB: One must not call raw_add_edge and raw_add_vertex manually, as it would break the internal invariants of the cycle detection algorithm. One must use instead the safe wrappers add_vertex and add_edge_or_detect_cycle that are provided as output of the Incremental_cycles.Make functor.
get_outgoing g v returns the list of successors of v in the graph.
raw_add_edge g v w inserts a new (directed) arc between vertices v and w.
v and w must have been previously added to the graph using raw_add_vertex, and the arc v->w must not already be in the graph.
raw_add_vertex g v inserts a new vertex v into the graph.
new_mark.get_level) of a new vertex must be 1.get_incoming) of a new vertex must be [] (the empty list).new_mark g generates a fresh mark.
More specifically, this mark must be different from all the marks previously returned by new_mark g (on the same graph g). It must also be different from all the marks currently associated to vertices of the graph g.
is_marked g v m tests whether the vertex v has mark m.
NB: is_marked g v m can only hold if set_mark g v m has been called previously.
get_level g v returns the level of node v.
It is either the value previously set by set_level, or the default value for a newly created vertex (i.e. 1, see raw_add_vertex).
get_incoming g v returns the list of "incoming" vertices of node v.
It corresponds to either the default value for a newly created vertex (i.e. the empty list, see raw_add_vertex), or the result of previous calls to clear_incoming and add_incoming.
clear_incoming g v sets the list of "incoming" vertices of v to be the empty list.
add_incoming g v w adds w to the list of "incoming" vertices of v.
get_parent g v returns the "parent" of node v, as set by set_parent.
Note: there is no default value for get_parent. It is fine for get_parent g v to fail if it is called while set_parent g v w has not be called beforehand.
set_parent g v w sets the "parent" of node v to be w.
All the operations provided by Raw_graph must run in constant time.