|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.javanetworkanalyzer.alg.GraphSearchAlgorithm<V,E>
org.javanetworkanalyzer.alg.Dijkstra<V,E>
V - VerticesE - Edgespublic class Dijkstra<V extends VDijkstra,E extends EdgeSPT>
Home-brewed implementation of Dijkstra's algorithm.
| Field Summary | |
|---|---|
protected static double |
TOLERANCE
Tolerance to be used when determining if two potential shortest paths have the same length. |
| Fields inherited from class org.javanetworkanalyzer.alg.GraphSearchAlgorithm |
|---|
currentStartNode, graph |
| Constructor Summary | |
|---|---|
Dijkstra(org.jgrapht.Graph<V,E> graph)
Constructor. |
|
| Method Summary | |
|---|---|
void |
calculate(V startNode)
Does a Dijkstra search from the given start node to all other nodes. |
void |
calculate(V startNode,
double radius)
Does a Dijkstra search from the given start node to all other nodes, limiting the search by the given radius. |
protected void |
init(V startNode)
Performs any initializations to be done at the start of the TraversalAlg.calculate(V) method. |
Map<V,Map<V,Double>> |
manyToMany(Set<V> sources,
Set<V> targets)
Performs a Dijkstra search from each source to each target using a oneToMany(V, java.util.Set search from each source. |
Map<V,Double> |
manyToOne(Set<V> sources,
V target)
Performs a Dijkstra search from each source to the given target by reversing the graph and using a oneToMany(V, java.util.Set from the target
to all the sources. |
protected void |
multipleShortestPathUpdate(V u,
V v,
E e)
Updates to be performed if the path to v through u is a new multiple shortest path. |
Map<V,Double> |
oneToMany(V source,
Set<V> targets)
Performs a Dijkstra search from the source, stopping once all the targets are found. |
double |
oneToOne(V source,
V target)
Performs a Dijkstra search from the source, stopping once the target is found. |
protected boolean |
preRelaxStep(V startNode,
V u)
Any work to be done using vertex u before relaxing the outgoing edges of u. |
TraversalGraph<V,E> |
reconstructTraversalGraph(double radius)
Returns the SPT from the last start node calculate(V) was called on,
limited by the given radius. |
protected void |
relax(V startNode,
V u,
E e,
PriorityQueue<V> queue)
Relaxes the edge outgoing from u and updates the queue appropriately. |
protected void |
shortestPathSoFarUpdate(V startNode,
V u,
V v,
Double uvWeight,
E e,
PriorityQueue<V> queue)
Updates to be performed if the path to v through u is the shortest path to v found so far. |
| Methods inherited from class org.javanetworkanalyzer.alg.GraphSearchAlgorithm |
|---|
outdegree, outgoingEdgesOf, outgoingEdgesOf, reconstructTraversalGraph, successorListOf |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final double TOLERANCE
| Constructor Detail |
|---|
public Dijkstra(org.jgrapht.Graph<V,E> graph)
graph - The graph.| Method Detail |
|---|
public void calculate(V startNode)
startNode - Start node
public void calculate(V startNode,
double radius)
startNode - Start noderadius - Radius by which to limit the searchprotected void init(V startNode)
GraphSearchAlgorithmTraversalAlg.calculate(V) method.
init in class GraphSearchAlgorithm<V extends VDijkstra,E extends EdgeSPT>startNode - Start node
protected boolean preRelaxStep(V startNode,
V u)
u - Vertex u.
protected void relax(V startNode,
V u,
E e,
PriorityQueue<V> queue)
u - Vertex u.e - Edge e.queue - The queue.
protected void shortestPathSoFarUpdate(V startNode,
V u,
V v,
Double uvWeight,
E e,
PriorityQueue<V> queue)
u - Vertex uv - Vertex vuvWeight - w(u,v)e - Edge equeue - Queue
protected void multipleShortestPathUpdate(V u,
V v,
E e)
u - Vertex uv - Vertex ve - Edge epublic TraversalGraph<V,E> reconstructTraversalGraph(double radius)
calculate(V) was called on,
limited by the given radius. The shortest path "tree" we return may
contain multiple shortest paths.
Note: GraphSearchAlgorithm.reconstructTraversalGraph() should not
be used when limiting by radius as it will include edges to vertices with
a distance greater than the radius.
radius - The radius to limit by
calculate(V)
was called on
public double oneToOne(V source,
V target)
source - Sourcetarget - Target
public Map<V,Double> oneToMany(V source,
Set<V> targets)
source - Sourcetargets - Targets
public Map<V,Double> manyToOne(Set<V> sources,
V target)
oneToMany(V, java.util.Set) from the target
to all the sources. If the graph is undirected, there is no need
to reverse the graph.
sources - Sourcestarget - Target
public Map<V,Map<V,Double>> manyToMany(Set<V> sources,
Set<V> targets)
oneToMany(V, java.util.Set) search from each source.
Note: Using oneToMany rather than manyToOne is more efficient since we
don't have to create an edge-reversed graph.
sources - Sourcestargets - Targets
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||