|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.graph.analysis.strategy.Strategy
ptolemy.graph.analysis.strategy.CachedStrategy
ptolemy.graph.analysis.strategy.FloydWarshallStrategy
ptolemy.graph.analysis.strategy.FloydWarshallAllPairShortestPathStrategy
public class FloydWarshallAllPairShortestPathStrategy
Computation of the all pair shortest path of a directed graph using the Floyd-Warshall algorithm. The result is in the form of two dimensional array (matrix). The first dimension is indexed by the source node label while the second one is indexed by the sink node label. In graphs that have multiple edges between two nodes obviously the edge with the minimum weight is being considered for the shortest path. The distance between a node and itself is being considered Double.MAX_VALUE, unless otherwise specified by a self edge for a cyclic graph. ((double[][])result())[i][i] would be the length of the shortest cycle that includes the node with label "i".
AllPairShortestPathAnalysis
Red (ssb) |
Red (shahrooz) |
Field Summary | |
---|---|
private double[][][] |
_allPairShortestPath
|
private ToDoubleMapping |
_edgeLengths
|
private int[][] |
_predecessorResult
|
private int[][][] |
_predecessors
|
Constructor Summary | |
---|---|
FloydWarshallAllPairShortestPathStrategy(Graph graph,
ToDoubleMapping edgeLengths)
Construct an AllPairShortestPathAnalyzer which works using the Floyd-Warshall strategy. |
Method Summary | |
---|---|
protected java.lang.Object |
_compute()
Compute the all pair shortest path of the graph in the form of two dimensional array (matrix). |
protected void |
_floydWarshallComputation(int k,
int i,
int j)
The FloydWarshall computation associated with this, analysis. |
private int[][] |
predecessors()
Return the node before the end node on the shortest path from a starting node to an ending node. |
java.util.List |
shortestPath(Node startNode,
Node endNode)
Return the nodes on the shortest path from the node startNode to the node endNode in the form of an ordered list. |
double |
shortestPathLength(Node startNode,
Node endNode)
Return the length of the shortest path from the node startNode to the node endNode. |
double[][] |
shortestPathMatrix()
Return the all pair shortest path of the graph in the form of two dimensional array (matrix). |
java.lang.String |
toString()
Return a description of the analyzer. |
boolean |
valid()
Check for compatibility between the analysis and the given graph. |
Methods inherited from class ptolemy.graph.analysis.strategy.CachedStrategy |
---|
_convertResult, _result, cachingStatus, disableCaching, enableCaching, getCachedResult, graph, obsolete, reset, setCachedResult |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface ptolemy.graph.analysis.analyzer.GraphAnalyzer |
---|
graph |
Field Detail |
---|
private ToDoubleMapping _edgeLengths
private int[][][] _predecessors
private int[][] _predecessorResult
private double[][][] _allPairShortestPath
Constructor Detail |
---|
public FloydWarshallAllPairShortestPathStrategy(Graph graph, ToDoubleMapping edgeLengths)
graph
- The given graph.edgeLengths
- The edge lengths.Method Detail |
---|
public java.util.List shortestPath(Node startNode, Node endNode)
shortestPath
in interface AllPairShortestPathAnalyzer
startNode
- The starting node of the path.endNode
- The ending node of the path.
public double shortestPathLength(Node startNode, Node endNode)
shortestPathLength
in interface AllPairShortestPathAnalyzer
startNode
- The starting node of the path.endNode
- The end node of the path.
public double[][] shortestPathMatrix()
shortestPathMatrix
in interface AllPairShortestPathAnalyzer
Graph.nodeLabel(ptolemy.graph.Node)
public java.lang.String toString()
toString
in interface Analyzer
toString
in class CachedStrategy
public boolean valid()
valid
in interface Analyzer
protected java.lang.Object _compute()
_compute
in class FloydWarshallStrategy
protected final void _floydWarshallComputation(int k, int i, int j)
_floydWarshallComputation
in class FloydWarshallStrategy
k
- The counting parameter of the first loop of the Floyd-Warshall
computation.i
- The counting parameter of the second loop of the Floyd-Warshall
computation.j
- The counting parameter of the third and last loop of the
Floyd-Warshall computation.private int[][] predecessors()
shortestPathMatrix()
method should be called
before this method in order to make the result consistent with the
current state (graph, edge values, ...).
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |