next up previous contents
Next: Adjacency Iterators (AdjIt) Up: Graphs and Iterators Previous: Adjacency Iterators for leaving

   
Adjacency Iterators for incoming edges (InAdjIt)

Definition

a variable it of class InAdjIt is an adjacency iterator that marks a node (which is fixed in contrast to linear node iterators) and iterates over the incoming edges of this node.

Creation

InAdjIt it; introduces a variable it of this class associated with no graph.

InAdjIt

it(graph G); introduces a variable it of this class associated with G.

The node is initialized by G.first_node() and the edge by G.first_in_edge(n) where n is the marked node.

InAdjIt

it(graph G, node n); introduces a variable it of this class marked with n and associated with G. The marked edge is initialized by G.first_in_edge(n).

Precondition: n is a node of G.

InAdjIt

it(graph G, node n, edge e);
    introduces a variable it of this class marked with n and e and associated with G.

Precondition: n is a node and e an edge of G and target(e)=n.

   

Operations

void it.init(graph G) associates it with G and marks it with n'=G.first_node() and G.first_adj_edge(n').
void it.init(graph G, node n) associates it with G and marks it with n and G.first_adj_edge(n).

Precondition: n is a node of G.

void it.init(graph G, node n, edge e)
    associates it with G and marks it with n and e.

Precondition: n is a node and e an edge of G and target(e)=n.

void it.update(edge e) it marks e afterwards.
void it.reset() resets it to G.first_in_edge(n) where G and n are the marked node and associated graph.
void it.insert(InAdjIt other) creates a new incoming edge from the marked node of it to the marked node of other. it is marked with the new edge afterwards. The marked node of it does not change.
void it.del() deletes the marked incoming edge, i.e. it.valid() returns false afterwards.

Precondition: it.valid() returns true.

void it.reset_end() resets it to G.last_in_edge(n) where G and n are the marked node and associated graph.
void it.make_invalid() makes it invalid, i.e. it.valid() will be false afterwards and it marks no node.
void it.update(node n) it marks n and the first incoming edge of n afterwards.
void it.update(node n, edge e)
    it marks n and e afterwards.
InAdjIt& it = it2 assigns it2 to it. This method returns a reference this method returns a reference to it.
bool it == it2 returns true if and only if it and it2 are equal, i.e. if the marked nodes and edges are equal.
bool it.has_node() returns true if and only if it marks a node.
bool it.eol() returns !it.valid() which is true if and only if there is no successor edge left, i.e. if all edges of the edge set are passed (eol: end of list).
bool it.valid() returns true if and only if end of sequence not yet passed, i.e. if there is an edge in the edge set that was not yet passed.
edge it.get_edge() returns the marked edge or nil if it.valid() returns false.
node it.get_node() returns the marked node or nil if it.has_node() returns false.
graph it.get_graph() returns the associated graph.
InAdjIt it.curr_adj() returns a new adjacency iterator that is associated with n'=source(e) and G.first_in_edge(n') where G is the associated graph.

Precondition: it.valid() returns true.

InAdjIt& ++it performs one step forward in the list of incoming edges of the marked node. If there is no successor edge, it.eol() will be true afterwards. This method returns a reference to it.

Precondition: it.valid() returns true.

InAdjIt& -it performs one step backward in the list of incoming edges of the marked node. If there is no predecesssor edge, it.eol() will be true afterwards. This method returns a reference to it.

Precondition: it.valid() returns true.

Implementation

Creation of an iterator and all methods take constant time.


next up previous contents
Next: Adjacency Iterators (AdjIt) Up: Graphs and Iterators Previous: Adjacency Iterators for leaving
LEDA research project
1998-10-02