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.

void algorithm.finish algo( )<br />

executes the algorithm until finished( ) is true, i.e.<br />

exactly if the stack is empty.<br />

bool algorithm.finished( ) returns true if the internal stack is empty.<br />

void algorithm.init(OutAdjIt s)<br />

Stacktype&<br />

4. Implementation<br />

initializes the internal stack with s.<br />

algorithm.get stack( ) gives direct access to internal stack.<br />

Each operation requires constant time.<br />

O(m + n) time.<br />

<strong>The</strong>refore, a normal depth-first search needs<br />

13.19 Topological Sort (flexible) ( GIT TOPOSORT<br />

)<br />

1. Definition<br />

An instance algorithm of class GIT TOPOSORT< OutAdjIt, Indeg, Queuetype > is an<br />

implementation of an algorithm that iterates over all nodes in some topological order, if<br />

the underlying graph is acyclic. An object of this class maintains an internal queue, which<br />

contains all nodes (in form of adjacency iterators where the current node is equal to the<br />

fixed node) that are not yet passed, but all its predecessors have been passed.<br />

Iterator version: <strong>The</strong>re is an iterator version of this algorithm: TOPO It. Usage is<br />

similar to that of node iterators without the ability to go backward in the sequence and<br />

only a graph is allowed at creation time. Additionally there is TOPO rev It which traverses<br />

the graph in reversed topological order.<br />

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

2. Creation<br />

GIT TOPOSORT< OutAdjIt, Indeg, Queuetype ><br />

algorithm(Indeg& indegree);<br />

creates an instance algorithm of this class bound to indeg.<br />

internal queue of adjacency iterators is empty.<br />

<strong>The</strong><br />

Preconditions:<br />

• Indeg is a data accessor that must provide both read and write access

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

Saved successfully!

Ooh no, something went wrong!