org.neo4j.graphalgo.impl.shortestpath
Class FloydWarshall<CostType>

java.lang.Object
  extended by org.neo4j.graphalgo.impl.shortestpath.FloydWarshall<CostType>
Type Parameters:
CostType - The datatype the edge weights are represented by.

public class FloydWarshall<CostType>
extends Object

This provides an implementation of the Floyd Warshall algorithm solving the all pair shortest path problem.

Author:
Patrik Larsson

Field Summary
protected  CostAccumulator<CostType> costAccumulator
           
protected  Comparator<CostType> costComparator
           
protected  CostEvaluator<CostType> costEvaluator
           
protected  boolean doneCalculation
           
protected  CostType infinitelyBad
           
protected  Set<Node> nodeSet
           
protected  Direction relationDirection
           
protected  Set<Relationship> relationshipSet
           
protected  CostType startCost
           
 
Constructor Summary
FloydWarshall(CostType startCost, CostType infinitelyBad, Direction relationDirection, CostEvaluator<CostType> costEvaluator, CostAccumulator<CostType> costAccumulator, Comparator<CostType> costComparator, Set<Node> nodeSet, Set<Relationship> relationshipSet)
           
 
Method Summary
 void calculate()
          Internal calculate method that will do the calculation.
 CostType getCost(Node node1, Node node2)
          This returns the cost for the shortest path between two nodes.
 List<Node> getPath(Node startNode, Node targetNode)
          This returns the shortest path between two nodes as list of nodes.
 void reset()
          This resets the calculation if we for some reason would like to redo it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

startCost

protected CostType startCost

infinitelyBad

protected CostType infinitelyBad

relationDirection

protected Direction relationDirection

costEvaluator

protected CostEvaluator<CostType> costEvaluator

costAccumulator

protected CostAccumulator<CostType> costAccumulator

costComparator

protected Comparator<CostType> costComparator

nodeSet

protected Set<Node> nodeSet

relationshipSet

protected Set<Relationship> relationshipSet

doneCalculation

protected boolean doneCalculation
Constructor Detail

FloydWarshall

public FloydWarshall(CostType startCost,
                     CostType infinitelyBad,
                     Direction relationDirection,
                     CostEvaluator<CostType> costEvaluator,
                     CostAccumulator<CostType> costAccumulator,
                     Comparator<CostType> costComparator,
                     Set<Node> nodeSet,
                     Set<Relationship> relationshipSet)
Parameters:
startCost - The cost for just starting (or ending) a path in a node.
infinitelyBad - A cost worse than all others. This is used to initialize the distance matrix.
costRelationType - The relationship type to traverse.
relationDirection - The direction in which the paths should follow the relationships.
costEvaluator -
costAccumulator -
costComparator -
nodeSet - The set of nodes the calculation should be run on.
relationshipSet - The set of relationships that should be processed.
See Also:
CostEvaluator}, CostAccumulator}, CostAccumulator} or {@link CostEvaluator}
Method Detail

reset

public void reset()
This resets the calculation if we for some reason would like to redo it.


calculate

public void calculate()
Internal calculate method that will do the calculation. This can however be called externally to manually trigger the calculation.


getCost

public CostType getCost(Node node1,
                        Node node2)
This returns the cost for the shortest path between two nodes.

Parameters:
node1 - The start node.
node2 - The end node.
Returns:
The cost for the shortest path.

getPath

public List<Node> getPath(Node startNode,
                          Node targetNode)
This returns the shortest path between two nodes as list of nodes.

Parameters:
startNode - The start node.
targetNode - The end node.
Returns:
The shortest path as a list of nodes.


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