|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.neo4j.graphalgo.impl.shortestpath.SingleSourceShortestPathBFS
public class SingleSourceShortestPathBFS
Breadth first search to find all shortest uniform paths from a node to all others. I.e. assume the cost 1 for all relationships. This can be done by Dijkstra with the right arguments, but this should be faster.
| Field Summary | |
|---|---|
protected long |
depth
|
protected HashMap<Node,Integer> |
distances
|
protected long |
maxDepth
|
protected HashMap<Node,List<Relationship>> |
predecessors
|
protected Direction |
relationShipDirection
|
protected RelationshipType[] |
relationShipTypes
|
protected Node |
startNode
|
| Constructor Summary | |
|---|---|
SingleSourceShortestPathBFS(Node startNode,
Direction relationShipDirection,
RelationshipType... relationShipTypes)
|
|
| Method Summary | |
|---|---|
boolean |
calculate()
Internal calculate method that will do the calculation. |
boolean |
calculate(Node targetNode)
Internal calculate method that will run the calculation until either the limit is reached or a result has been generated for a given node. |
Integer |
getCost(Node targetNode)
A call to this will run the algorithm, if not already done, and return the cost for the shortest paths between the start node and the target node. |
Direction |
getDirection()
This can be used to retrieve the Direction in which relationships should be in the shortest path(s). |
List<PropertyContainer> |
getPath(Node targetNode)
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(Node targetNode)
A call to this will run the algorithm, if not already done, and return the found path to the target node if found as a list of nodes. |
List<Relationship> |
getPathAsRelationships(Node targetNode)
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(Node targetNode)
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(Node targetNode)
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(Node targetNode)
A call to this will run the algorithm to find all shortest paths, if not already done, and return them as lists of relationships. |
List<Node> |
getPredecessorNodes(Node node)
|
Map<Node,List<Relationship>> |
getPredecessors()
This can be used to retrieve the entire data structure representing the predecessors for every node. |
RelationshipType[] |
getRelationshipTypes()
This can be used to retrieve the types of relationships that are traversed. |
void |
limitDepth(long maxDepth)
This sets the maximum depth to scan. |
boolean |
processNextNode()
Iterator-style "next" method. |
void |
reset()
This resets the calculation if we for some reason would like to redo it. |
void |
setStartNode(Node node)
This sets the start node. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Node startNode
protected Direction relationShipDirection
protected RelationshipType[] relationShipTypes
protected HashMap<Node,Integer> distances
protected HashMap<Node,List<Relationship>> predecessors
protected long maxDepth
protected long depth
| Constructor Detail |
|---|
public SingleSourceShortestPathBFS(Node startNode,
Direction relationShipDirection,
RelationshipType... relationShipTypes)
| Method Detail |
|---|
public void limitDepth(long maxDepth)
public void setStartNode(Node node)
SingleSourceShortestPath
setStartNode in interface SingleSourceShortestPath<Integer>node - The start node.SingleSourceShortestPathpublic void reset()
SingleSourceShortestPath
reset in interface SingleSourceShortestPath<Integer>SingleSourceShortestPathpublic Integer getCost(Node targetNode)
SingleSourceShortestPath
getCost in interface SingleSourceShortestPath<Integer>SingleSourceShortestPathpublic List<PropertyContainer> getPath(Node targetNode)
SingleSourceShortestPath
getPath in interface SingleSourceShortestPath<Integer>SingleSourceShortestPathpublic List<Node> getPathAsNodes(Node targetNode)
SingleSourceShortestPath
getPathAsNodes in interface SingleSourceShortestPath<Integer>SingleSourceShortestPathpublic List<Relationship> getPathAsRelationships(Node targetNode)
SingleSourceShortestPath
getPathAsRelationships in interface SingleSourceShortestPath<Integer>SingleSourceShortestPathpublic List<List<PropertyContainer>> getPaths(Node targetNode)
SingleSourceShortestPath
getPaths in interface SingleSourceShortestPath<Integer>SingleSourceShortestPathpublic List<List<Node>> getPathsAsNodes(Node targetNode)
SingleSourceShortestPath
getPathsAsNodes in interface SingleSourceShortestPath<Integer>SingleSourceShortestPathpublic List<List<Relationship>> getPathsAsRelationships(Node targetNode)
SingleSourceShortestPath
getPathsAsRelationships in interface SingleSourceShortestPath<Integer>SingleSourceShortestPathpublic boolean processNextNode()
public boolean calculate()
public boolean calculate(Node targetNode)
public List<Node> getPredecessorNodes(Node node)
getPredecessorNodes in interface SingleSourceShortestPath<Integer>SingleSourceShortestPathpublic Map<Node,List<Relationship>> getPredecessors()
SingleSourceShortestPath
getPredecessors in interface SingleSourceShortestPath<Integer>SingleSourceShortestPathpublic Direction getDirection()
SingleSourceShortestPath
getDirection in interface SingleSourceShortestPath<Integer>SingleSourceShortestPathpublic RelationshipType[] getRelationshipTypes()
SingleSourceShortestPath
getRelationshipTypes in interface SingleSourceShortestPath<Integer>SingleSourceShortestPath
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||