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.

4. Operations<br />

<strong>The</strong> interface consists of two parts. <strong>The</strong> first part - the basic interface - is independent<br />

from the actual graph category, the specified operations are common to all graph. <strong>The</strong><br />

second part of the interface is different for every category and contains macros to iterate<br />

over incident edges or adjacent nodes and methods for traversing a given edge.<br />

void G.start construction(int n, int m)<br />

starts the construction phase for a graph<br />

with up to n nodes and m edges.<br />

node G.new node( ) creates a new node, appends it to V , and returns<br />

it. <strong>The</strong> operation may only be called<br />

during construction phase and at most n<br />

times.<br />

edge G.new edge(node v, node w)<br />

void G.finish construction( )<br />

creates the edge (v, w), appends it to E, and<br />

returns it. <strong>The</strong> operation may only be called<br />

during construction phase and at most m<br />

times.<br />

Precondition: All edges (u, v) of G with<br />

index(u) < index(v) have been created before.<br />

terminates the construction phase.<br />

int forall nodes(v, G) v iterates over the node sequence.<br />

int forall edges(e, G) e iterates over the edge sequence.<br />

Static Directed Graphs (static graph)<br />

For this category the basic interface of static graph is extended by the operations:<br />

node G.target(edge e) returns the target node of e.<br />

node G.outdeg(node v) returns the number of outgoing edges of v.<br />

int forall out edges(e, v) e iterates over all edges with source(e) = v.<br />

Static Bidirectional Graphs (static graph)<br />

For this category the basic interface of static graph is extended by the operations:<br />

node G.target(edge e) returns the target node of e.<br />

node G.source(edge e) returns the source node of e.

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

Saved successfully!

Ooh no, something went wrong!