net.spy.util
Class ShortestPathFinder

java.lang.Object
  extended by net.spy.util.ShortestPathFinder

public class ShortestPathFinder
extends Object

This is a utility class for finding the least costly paths from each node from a collection to all nodes to which they link.

The basic process is to create some SPNodes and link them together arbitrarily with SPVertex instances. Once the graph is complete, obtain an instance of ShortestPathFinder and have it calculate the paths for any (or all) nodes. calculatePaths may be called as many times as you need, it will reset the paths and build new ones.

For example, consider the graph to the right. The following will be true (this is actually my test case):

FromToNext HopCost
AAn/an/a
ABB10
ACC15
ADC25
AEC25
AFC25
AGC35
BAn/an/a
BBC220
BCC10
BDC20
BEC20
BFC20
BGC30
CAn/an/a
CBF210
CCD110
CDD10
CEE10
CFF10
CGF20
DAn/an/a
DBC310
DCC100
DDC110
DEC110
DFC110
DGC120
FromToNext HopCost
EAn/an/a
EBn/an/a
ECn/an/a
EDn/an/a
EEE10
EFn/an/a
EGn/an/a
FAn/an/a
FBB200
FCB210
FDB220
FEB220
FFB220
FGG10
GAn/an/a
GBn/an/a
GCn/an/a
GDn/an/a
GEn/an/a
GFn/an/a
GGn/an/a


Constructor Summary
ShortestPathFinder()
          Get an instance of ShortestPathFinder.
 
Method Summary
 void calculatePaths(Collection<? extends SPNode<?>> nodes)
          Calculate all the paths for all the nodes in the given collection.
 void calculatePaths(SPNode<?> node)
          Calculate all of the paths for a single node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShortestPathFinder

public ShortestPathFinder()
Get an instance of ShortestPathFinder.

Method Detail

calculatePaths

public void calculatePaths(Collection<? extends SPNode<?>> nodes)
Calculate all the paths for all the nodes in the given collection.

Parameters:
nodes - the nodes to calculate

calculatePaths

public void calculatePaths(SPNode<?> node)
Calculate all of the paths for a single node.

Parameters:
node - the node from which to calculate paths


Copyright © 1995-2007 SPY Internetworking. All Rights Reserved.