31.01.2014 Views

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

13.16 Node Attribute Accessors ( node attribute da<br />

)<br />

1. Definition<br />

An instance da of class node attribute da manages the access to a node parameter<br />

with type T of a parameterized graph GRAPH.<br />

Classes edge attribute da is defined completely analogously.<br />

#include < <strong>LEDA</strong>/graph/graph iterator.h ><br />

2. Creation<br />

node attribute da da;<br />

introduces a variable da of this class.<br />

3. Operations<br />

T<br />

void<br />

get(const node attribute da& ma, const Iter& it)<br />

returns the associated value of it for this accessor.<br />

set(node attribute da& ma, const Iter& it, T val)<br />

sets the associated value of it for this accessor to the<br />

given value.<br />

4. Implementation<br />

Constant Overhead.<br />

5. Example<br />

Given a parameterized graph G with nodes associated with colours, we want to count the<br />

number of red nodes. Since we have the template function of sect. 13.13 we can easily use<br />

it to do the computation:<br />

int count_red(GRAPH G) {<br />

node_attribute_da Color;<br />

return count_red_t(G,Color); }

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!