V - the type of the vertices of the graphpublic class PriorityQueue<V extends Vertible<V>> extends Object
vertex with the minimum key.
Usually, the key is the distance to a given start vertex in a
weighted graph.
The priority queue class is used in the
Dijkstra algorithm.Vertible,
WeightedGraph.dijkstra(int)| Constructor and Description |
|---|
PriorityQueue(V[] vertices)
Creates a priority queue containing the input vertices.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
decreaseKey(V v,
double d)
Decreases the key of the specified element v to the value d.
|
V |
extractMin()
Returns the minimum of this priority queue and deletes it from the queue.
|
V |
getRoot()
Returns the root of the heap representing this priority queue.
|
int |
size()
Returns the number of elements in this priority queue.
|
String |
toString()
Returns a string representationj of this priority queue.
|
public PriorityQueue(V[] vertices)
vertices - an array of verticespublic int size()
public V getRoot()
public V extractMin()
public boolean decreaseKey(V v, double d)
v - the vertex whose key is to be decreasedd - the new value of the keytrue if and only if the new value d is less
than the current key value