|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.neo4j.graphalgo.impl.shortestpath.Dijkstra<CostType>
CostType - The datatype the edge weights will be represented by.public class Dijkstra<CostType>
Dijkstra class. This class can be used to perform shortest path computations between two nodes. The search is made simultaneously from both the start node and the end node. Note that per default, only one shortest path will be searched for. This will be done when the path or the cost is asked for. If at some later time getPaths is called to get all the paths, the calculation is redone. In order to avoid this double computation when all paths are desired, be sure to call getPaths (or calculateMultiple) before any call to getPath or getCost (or calculate) is made.
| Nested Class Summary | |
|---|---|
protected class |
Dijkstra.DijstraIterator
A DijkstraIterator computes the distances to nodes from a specified starting node, one at a time, following the dijkstra algorithm. |
| Field Summary | |
|---|---|
protected boolean |
calculateAllShortestPaths
|
protected CostAccumulator<CostType> |
costAccumulator
|
protected Comparator<CostType> |
costComparator
|
protected CostEvaluator<CostType> |
costEvaluator
|
protected RelationshipType[] |
costRelationTypes
|
protected boolean |
doneCalculation
|
protected Node |
endNode
|
protected CostType |
foundPathsCost
|
protected Set<Node> |
foundPathsMiddleNodes
|
protected CostType |
maxCost
|
protected long |
maxNodesToTraverse
|
protected long |
maxRelationShipsToTraverse
|
protected long |
numberOfNodesTraversed
|
protected long |
numberOfTraversedRelationShips
|
protected HashMap<Node,List<Relationship>> |
predecessors1
|
protected HashMap<Node,List<Relationship>> |
predecessors2
|
protected Direction |
relationDirection
|
protected CostType |
startCost
|
protected Node |
startNode
|
| Constructor Summary | |
|---|---|
Dijkstra(CostType startCost,
Node startNode,
Node endNode,
CostEvaluator<CostType> costEvaluator,
CostAccumulator<CostType> costAccumulator,
Comparator<CostType> costComparator,
Direction relationDirection,
RelationshipType... costRelationTypes)
|
|
| Method Summary | |
|---|---|
boolean |
calculate()
Makes the main calculation If some limit is set, the shortest path(s) that could be found within those limits will be calculated. |
boolean |
calculateMultiple()
Same as calculate(), but will set the flag to calculate all shortest paths. |
CostType |
getCost()
A call to this will run the algorithm to find the cost for the shortest paths between the start node and the end node, if not calculated before. |
Direction |
getDirection()
This can be used to retrieve the Direction in which relationships should be in the shortest path(s). |
List<PropertyContainer> |
getPath()
A call to this will run the algorithm to find a single shortest path, if not already done, and return it as an alternating list of Node/Relationship. |
List<Node> |
getPathAsNodes()
A call to this will run the algorithm to find a single shortest path, if not already done, and return it as a list of nodes. |
List<Relationship> |
getPathAsRelationships()
A call to this will run the algorithm to find a single shortest path, if not already done, and return it as a list of Relationships. |
List<List<PropertyContainer>> |
getPaths()
A call to this will run the algorithm to find all shortest paths, if not already done, and return them as alternating lists of Node/Relationship. |
List<List<Node>> |
getPathsAsNodes()
A call to this will run the algorithm to find all shortest paths, if not already done, and return them as lists of nodes. |
List<List<Relationship>> |
getPathsAsRelationships()
A call to this will run the algorithm to find all shortest paths, if not already done, and return them as lists of relationships. |
RelationshipType[] |
getRelationshipTypes()
This can be used to retrieve the types of relationships that are traversed. |
void |
limitMaxCostToTraverse(CostType maxCost)
Set the evaluator for pruning the paths when the maximum cost is exceeded. |
void |
limitMaxNodesToTraverse(long maxNodesToTraverse)
This sets the maximum depth in the form of a maximum number of nodes to scan. |
void |
limitMaxRelationShipsToTraverse(long maxRelationShipsToTraverse)
This sets the maximum depth in the form of a maximum number of relationships to follow. |
protected boolean |
limitReached()
|
protected boolean |
limitReached(CostType cost1,
CostType cost2)
|
void |
reset()
Resets the result data to force the computation to be run again when some result is asked for. |
void |
setEndNode(Node endNode)
Set the end node. |
void |
setStartNode(Node startNode)
Set the start node. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected CostType startCost
protected Node startNode
protected Node endNode
protected RelationshipType[] costRelationTypes
protected Direction relationDirection
protected CostEvaluator<CostType> costEvaluator
protected CostAccumulator<CostType> costAccumulator
protected Comparator<CostType> costComparator
protected boolean calculateAllShortestPaths
protected long maxRelationShipsToTraverse
protected long numberOfTraversedRelationShips
protected long maxNodesToTraverse
protected long numberOfNodesTraversed
protected CostType maxCost
protected boolean doneCalculation
protected Set<Node> foundPathsMiddleNodes
protected CostType foundPathsCost
protected HashMap<Node,List<Relationship>> predecessors1
protected HashMap<Node,List<Relationship>> predecessors2
| Constructor Detail |
|---|
public Dijkstra(CostType startCost,
Node startNode,
Node endNode,
CostEvaluator<CostType> costEvaluator,
CostAccumulator<CostType> costAccumulator,
Comparator<CostType> costComparator,
Direction relationDirection,
RelationshipType... costRelationTypes)
startCost - Starting cost for both the start node and the end nodestartNode - the start nodeendNode - the end nodecostRelationTypes - the relationship that should be included in the
pathrelationDirection - relationship direction to followcostEvaluator - the cost function per relationshipcostAccumulator - adding up the path costcostComparator - comparing to path costs| Method Detail |
|---|
protected boolean limitReached()
protected boolean limitReached(CostType cost1,
CostType cost2)
public void reset()
reset in interface SingleSourceSingleSinkShortestPath<CostType>public boolean calculateMultiple()
public boolean calculate()
public CostType getCost()
SingleSourceSingleSinkShortestPath
getCost in interface SingleSourceSingleSinkShortestPath<CostType>public List<List<PropertyContainer>> getPaths()
SingleSourceSingleSinkShortestPath
getPaths in interface SingleSourceSingleSinkShortestPath<CostType>public List<List<Node>> getPathsAsNodes()
SingleSourceSingleSinkShortestPath
getPathsAsNodes in interface SingleSourceSingleSinkShortestPath<CostType>public List<List<Relationship>> getPathsAsRelationships()
SingleSourceSingleSinkShortestPath
getPathsAsRelationships in interface SingleSourceSingleSinkShortestPath<CostType>public List<PropertyContainer> getPath()
SingleSourceSingleSinkShortestPath
getPath in interface SingleSourceSingleSinkShortestPath<CostType>public List<Node> getPathAsNodes()
SingleSourceSingleSinkShortestPath
getPathAsNodes in interface SingleSourceSingleSinkShortestPath<CostType>public List<Relationship> getPathAsRelationships()
SingleSourceSingleSinkShortestPath
getPathAsRelationships in interface SingleSourceSingleSinkShortestPath<CostType>public void limitMaxRelationShipsToTraverse(long maxRelationShipsToTraverse)
maxRelationShipsToTraverse - public void limitMaxNodesToTraverse(long maxNodesToTraverse)
maxRelationShipsToTraverse - public void setEndNode(Node endNode)
setEndNode in interface SingleSourceSingleSinkShortestPath<CostType>endNode - the endNode to setpublic void setStartNode(Node startNode)
setStartNode in interface SingleSourceSingleSinkShortestPath<CostType>startNode - the startNode to setpublic Direction getDirection()
SingleSourceSingleSinkShortestPath
getDirection in interface SingleSourceSingleSinkShortestPath<CostType>public RelationshipType[] getRelationshipTypes()
SingleSourceSingleSinkShortestPath
getRelationshipTypes in interface SingleSourceSingleSinkShortestPath<CostType>public void limitMaxCostToTraverse(CostType maxCost)
evaluator - The evaluator for
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||