next up previous contents index
Next: Edge Iterators ( EdgeIt Up: Graphs and Iterators Previous: Introduction   Contents   Index


Node Iterators ( NodeIt )

Definition

a variable it of class NodeIt is a linear node iterator that iterates over the node set of a graph; the current node of an iterator object is said to be ``marked'' by this object.

#include < LEDA/graph _iterator.h >

Creation

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

NodeIt it(leda_graph G) introduces a variable it of this class associated with G.

The graph is initialized by G. The node is initialized by G.first_node().

NodeIt it(leda_graph G, leda_node n)
    introduces a variable it of this class marked with n and associated with G.

Precondition: n is a node of G.

Operations

void it.init(leda_graph G) associates it with G and marks it with G.first_node().

void it.init(leda_graph G, leda_node v)
    associates it with G and marks it with v.

void it.reset() resets it to G.first_node(), where G is the associated graph.

void it.make_invalid() makes it invalid, i.e. it.valid() will be false afterwards and it marks no node.

void it.reset_end() resets it to G.last_node(), where G is the associated graph.

void it.update(leda_node n) it marks n afterwards.

void it.insert() creates a new node and it marks it afterwards.

void it.del() deletes the marked node, i.e. it.valid() returns false afterwards.

Precondition: it.valid() returns true.

NodeIt& it = it2 it is afterwards associated with the same graph and node as it2. 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 are equal.

leda_node it.get_node() returns the marked node or nil if it.valid() returns false.

leda_graph it.get_graph() returns the associated graph.

bool it.valid() returns true if and only if end of sequence not yet passed, i.e. if there is a node in the node set that was not yet passed.

bool it.eol() returns !it.valid() which is true if and only if there is no successor node left, i.e. if all nodes of the node set are passed (eol: end of list).

NodeIt& ++it performs one step forward in the list of nodes of the associated graph. If there is no successor node, it.eol() will be true afterwards. This method returns a reference to it.

Precondition: it.valid() returns true.

NodeIt& -it performs one step backward in the list of nodes of the associated graph. If there is no predecessor node, 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 index
Next: Edge Iterators ( EdgeIt Up: Graphs and Iterators Previous: Introduction   Contents   Index
LEDA research project
2000-02-09