next up previous contents index
Next: Breadth First Search (flexible) Up: Graphs and Iterators Previous: Node Member Accessors (   Contents   Index


Node Attribute Accessors ( node_attribute_da )

Definition

An instance da of class node_attribute_da<T> manages the access to a node parameter with type T of a parameterized graph GRAPH<T,?>.

Classes edge_attribute_da<T> is defined completely analogously.

#include < LEDA/graph _iterator.h >

Creation

node_attribute_da<T> da introduces a variable da of this class.

Operations

T get(node_attribute_da<T> ma, Iter it)
    returns the associated value of it for this accessor.

void set(node_attribute_da<T>& ma, Iter it, T val)
    sets the associated value of it for this accessor to the given value.

Implementation

Constant Overhead.

Example

Given a parameterized graph G with nodes associated with colours, we want to count the number of red nodes. Since we have the template function of sect. node_array_da we can easily use it to do the computation:


  int count_red(GRAPH<color,double> G) {
    node_attribute_da<color> Color;
    return count_red_t(G,Color); }


next up previous contents index
Next: Breadth First Search (flexible) Up: Graphs and Iterators Previous: Node Member Accessors (   Contents   Index
LEDA research project
2000-02-09