|
datastructures | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.datastructures.Dijkstra
Dijkstra's algorithm for the single-source shortest path problem in an undirected graph whose edges have integer weights.
To execute the algorithm, use the execute
method, and then make
subsequent calls to the getDist
method to
obtain the shortest distance from the start to any given vertex.
Field Summary | |
protected Object |
DIST
Attribute for vertex distances |
protected Object |
ENTRY
Decoration key for entries in the priority queue |
protected Graph |
graph
Input graph. |
static int |
INFINITE
Infinity value. |
protected AdaptablePriorityQueue |
Q
Auxiliary priority queue. |
protected Object |
WEIGHT
Decoration key for edge weights |
Constructor Summary | |
Dijkstra()
|
Method Summary | |
protected void |
dijkstraVisit(Vertex v)
The actual execution of Dijkstra's algorithm. |
void |
execute(Graph g,
Vertex s,
Object w)
Executes Dijkstra's algorithm. |
protected int |
getDist(Entry e)
Get the distance of a vertex given its entry |
int |
getDist(Vertex u)
Get the distance of a vertex from the source vertex. |
protected Entry |
getEntry(Vertex v)
Get the entry decoration of a vertex. |
protected Vertex |
getVertex(Entry e)
Get the vertex associated with an entry |
protected void |
removeEntry(Vertex v)
Remove the entry decoration of a vertex |
protected void |
setDist(Vertex v,
int d)
Set the distance of a vertex. |
protected void |
setEntry(Vertex v,
Entry e)
Set the entry decoration of a vertex |
protected int |
weight(Edge e)
Get the weight of an edge |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int INFINITE
protected Graph graph
protected Object WEIGHT
protected AdaptablePriorityQueue Q
protected Object DIST
protected Object ENTRY
Constructor Detail |
public Dijkstra()
Method Detail |
public void execute(Graph g, Vertex s, Object w)
g
- Input graphs
- Source vertexw
- Weight decoration objectpublic int getDist(Vertex u)
execute
has been called.
u
- Start vertex for the shortest path treeprotected void dijkstraVisit(Vertex v)
v
- source vertex.protected int weight(Edge e)
protected void setDist(Vertex v, int d)
protected Entry getEntry(Vertex v)
protected void setEntry(Vertex v, Entry e)
protected void removeEntry(Vertex v)
protected Vertex getVertex(Entry e)
protected int getDist(Entry e)
|
datastructures | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |