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.

Chapter 12<br />

Graph Algorithms<br />

This chapter gives a summary of the graph algorithms contained in <strong>LEDA</strong>, basic graph<br />

algorithms for reachability problems, shortest path algorithms, matching algorithms, flow<br />

algorithms, . . . .<br />

All graph algorithms are generic, i.e., they accept instances of any user defined parameterized<br />

graph type GRAP H as arguments.<br />

All graph algorithms are available by including the header file<br />

. Alternatively, one may include a more specific header file.<br />

An important subclass of graph algorithms are network algorithms. <strong>The</strong> input to most<br />

network algorithms is a graph whose edges or nodes are labeled with numbers, e.g.,<br />

shortest path algorithms get edge costs, network flow algorithms get edge capacities,<br />

and min cost flow algorithms get edge capacities and edge costs. We use NT to denote<br />

the number type used for the edge and node labels.<br />

Most network algorithms come in three kinds: A templated version in which NT is a<br />

template parameter, and reinstantiated and precompiled versions for the number types<br />

int (always) and double (except for a small number of functions). <strong>The</strong> function name of the<br />

templated version ends in T. Thus MAX FLOW T is the name of the templated version<br />

of the max flow algorithm and MAX FLOW is the name of the instantiated version.<br />

In order to use the templated version a file must be<br />

included, e.g., in order to use the templated version of the maxflow algorithm, one must<br />

include <br />

Special care should be taken when using network algorithms with a number type NT<br />

that can incur rounding error, e.g., the type double. <strong>The</strong> functions perform correctly if<br />

the arithmetic is exact. This is the case if all numerical values in the input are integers<br />

(albeit stored as a number of type NT ), if none of the intermediate results exceeds the<br />

maximal integer representable by the number type (2 52 in the case of doubles), and if no<br />

round-off errors occur during the computation. We give more specific information on the<br />

329

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

Saved successfully!

Ooh no, something went wrong!