org.neo4j.graphalgo.impl.shortestpath
Class Dijkstra.DijstraIterator

java.lang.Object
  extended by org.neo4j.graphalgo.impl.shortestpath.Dijkstra.DijstraIterator
All Implemented Interfaces:
Iterator<Node>
Enclosing class:
Dijkstra<CostType>

protected class Dijkstra.DijstraIterator
extends Object
implements Iterator<Node>

A DijkstraIterator computes the distances to nodes from a specified starting node, one at a time, following the dijkstra algorithm.

Author:
Patrik Larsson

Field Summary
protected  boolean allShortestPathsHasBeenFound
           
protected  boolean backwards
           
protected  HashMap<Node,CostType> myDistances
           
protected  HashMap<Node,CostType> mySeen
           
protected  boolean oneShortestPathHasBeenFound
           
protected  HashMap<Node,CostType> otherDistances
           
protected  HashMap<Node,CostType> otherSeen
           
protected  HashMap<Node,List<Relationship>> predecessors
           
protected  DijkstraPriorityQueue<CostType> queue
           
protected  Node startNode
           
 
Constructor Summary
Dijkstra.DijstraIterator(Node startNode, HashMap<Node,List<Relationship>> predecessors, HashMap<Node,CostType> mySeen, HashMap<Node,CostType> otherSeen, HashMap<Node,CostType> myDistances, HashMap<Node,CostType> otherDistances, boolean backwards)
           
 
Method Summary
protected  void checkForPath(Node currentNode, CostType currentCost, HashMap<Node,CostType> otherSideDistances)
          This checks if a node has been seen by the other iterator/traverser as well.
protected  Direction getDirection()
           
 boolean hasNext()
           
protected  void InitQueue()
           
 boolean isDone()
           
 Node next()
           
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

startNode

protected Node startNode

predecessors

protected HashMap<Node,List<Relationship>> predecessors

mySeen

protected HashMap<Node,CostType> mySeen

otherSeen

protected HashMap<Node,CostType> otherSeen

myDistances

protected HashMap<Node,CostType> myDistances

otherDistances

protected HashMap<Node,CostType> otherDistances

backwards

protected boolean backwards

queue

protected DijkstraPriorityQueue<CostType> queue

oneShortestPathHasBeenFound

protected boolean oneShortestPathHasBeenFound

allShortestPathsHasBeenFound

protected boolean allShortestPathsHasBeenFound
Constructor Detail

Dijkstra.DijstraIterator

public Dijkstra.DijstraIterator(Node startNode,
                                HashMap<Node,List<Relationship>> predecessors,
                                HashMap<Node,CostType> mySeen,
                                HashMap<Node,CostType> otherSeen,
                                HashMap<Node,CostType> myDistances,
                                HashMap<Node,CostType> otherDistances,
                                boolean backwards)
Method Detail

getDirection

protected Direction getDirection()
Returns:
The direction to use when searching for relations/edges

InitQueue

protected void InitQueue()

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator<Node>

remove

public void remove()
Specified by:
remove in interface Iterator<Node>

checkForPath

protected void checkForPath(Node currentNode,
                            CostType currentCost,
                            HashMap<Node,CostType> otherSideDistances)
This checks if a node has been seen by the other iterator/traverser as well. In that case a path has been found. In that case, the total cost for the path is calculated and compared to previously found paths.

Parameters:
currentNode - The node to be examined.
currentCost - The cost from the start node to this node.
otherSideDistances - Map over distances from other side. A path is found and examined if this contains currentNode.

next

public Node next()
Specified by:
next in interface Iterator<Node>

isDone

public boolean isDone()


Copyright © 2002-2012 The Neo4j Graph Database Project. All Rights Reserved.