com.ch.odi.common.graphs
Class Pathfinder

java.lang.Object
  |
  +--com.ch.odi.common.graphs.Pathfinder

public class Pathfinder
extends Object

Title: Finds the shortest path between two nodes in a graph. Description: Copyright: Copyright (c) 2002 Ortwin Glück Company:


Constructor Summary
Pathfinder(Graph g)
           
 
Method Summary
 Stack findShortestPath(Object start, Collection ends)
          Finds the shortest path from a start node to the closest of end nodes.
 Stack findShortestPath(Object start, Object end)
          Finds the shortest path between two nodes.
 void setHopLimit(int limit)
          Sets the maximum number of hops.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Pathfinder

public Pathfinder(Graph g)
Method Detail

findShortestPath

public Stack findShortestPath(Object start,
                              Object end)
Finds the shortest path between two nodes.
Parameters:
start - The node to start with
end - The end node

findShortestPath

public Stack findShortestPath(Object start,
                              Collection ends)
Finds the shortest path from a start node to the closest of end nodes.
Parameters:
start - The node to start with
end - A list of alternative end nodes. Using a HashSet is recommended as performance is best.

setHopLimit

public void setHopLimit(int limit)
Sets the maximum number of hops. A value of 0 disables the hop limit.