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.

11.20 Node Priority Queues ( node pq )<br />

1. Definition<br />

An instance Q of the parameterized data type node pq is a partial function from the<br />

nodes of a graph G to a linearly ordered type P of priorities. <strong>The</strong> priority of a node is<br />

sometimes called the information of the node. For every graph G only one node pq<br />

may be used and every node of G may be contained in the queue at most once (cf. section<br />

8.1 for general priority queues).<br />

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

2. Creation<br />

node pq Q(const graph t& G);<br />

creates an instance Q ot type node pq for the nodes of graph G<br />

with dom(Q) = ∅.<br />

3. Operations<br />

void Q.insert(node v, const P & x)<br />

adds the node v with priority x to Q.<br />

Precondition: v ∉ dom(Q).<br />

const P & Q.prio(node v) returns the priority of node v.<br />

Precondition: v ∈ dom(Q).<br />

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

void Q.decrease p(node v, const P & x)<br />

makes x the new priority of node v.<br />

Precondition: x ≤ Q.prio(v).<br />

node Q.find min( ) returns a node with minimal priority (nil if Q is empty).<br />

void Q.del(node v) removes the node v from Q.<br />

node Q.del min( ) removes a node with minimal priority from Q and returns<br />

it (nil if Q is empty).<br />

node Q.del min(P & x) as above, in addition the priority of the removed node<br />

is assigned to x.<br />

void Q.clear( ) makes Q the empty node priority queue.<br />

int Q.size( ) returns |dom(Q)|.<br />

int Q.empty( ) returns true if Q is the empty node priority queue, false<br />

otherwise.

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

Saved successfully!

Ooh no, something went wrong!