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.

OutAdjIt algorithm.curr adj( ) returns the an adjacency iterator that is currently adjacent<br />

to current( ).<br />

bool algorithm.is pred( ) returns true if the current iterator satisfies the dijkstra<br />

condition. Can be used to compute the predecessors.<br />

void algorithm.next( ) performs one iteration of the core loop of the algorithm.<br />

void algorithm.finish algo( )<br />

4. Example<br />

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

exactly if the priority queue is empty.<br />

Class GIT DIJKSTRA may be used in a deeper layer in a hierarchy of classes and functions.<br />

For example, you may write a function which computes shortes path distances with given<br />

iterators and data accessors:<br />

template<br />

void GIT_dijkstra_core(OutAdjIt s, Length& length, Distance& distance,<br />

PriorityQueue& pq, QueueItem& qi) {<br />

GIT_DIJKSTRA<br />

internal_dijk(length,distance,qi);<br />

internal_dijk.get_queue()=pq;<br />

set(distance,s,distance.value_null);<br />

if (s.valid()) {<br />

internal_dijk.init(s);<br />

internal_dijk.finish_algo();<br />

}<br />

}<br />

In another layer, you would instantiate these iterators and data acessors for a graph and<br />

invoke this function.<br />

5. Implementation<br />

<strong>The</strong> asymptotic complexity is O(m + n · T (n)), where T (n) is the(possibly amortized)<br />

complexity of a single queue update.<br />

For the priority queues described in Chapter 8.1, it is T (n) = O(log n).

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

Saved successfully!

Ooh no, something went wrong!