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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

11.16 Sets of Nodes ( node set )<br />

1. Definition<br />

An instance S of the data type node set is a subset of the nodes of a graph G. S is said<br />

to be valid for the nodes of G.<br />

#include < <strong>LEDA</strong>/graph/node set.h ><br />

2. Creation<br />

node set<br />

S(const graph& G);<br />

creates an instance S of type node set valid for all nodes currently<br />

contained in graph G and initializes it to the empty set.<br />

3. Operations<br />

void S.insert(node x) adds node x to S.<br />

void S.del(node x) removes node x from S.<br />

bool S.member(node x) returns true if x in S, false otherwise.<br />

node S.choose( ) returns a node of S.<br />

int S.size( ) returns the size of S.<br />

bool S.empty( ) returns true iff S is the empty set.<br />

void S.clear( ) makes S the empty set.<br />

4. Implementation<br />

A node set S for a graph G is implemented by a combination of a list L of nodes and a<br />

node array of list items associating with each node its position in L. All operations take<br />

constant time, except for clear which takes time O(S). <strong>The</strong> space requirement is O(n),<br />

where n is the number of nodes of G.

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

Saved successfully!

Ooh no, something went wrong!