net.walend.measured
Class AbstractShortestGEDistances

java.lang.Object
  |
  +--net.walend.measured.AbstractShortestGEDistances
All Implemented Interfaces:
HasState, java.io.Serializable, ShortestGEDistances
Direct Known Subclasses:
DijkstraShortestGEDistances, FloydWarshallShortestGEDistances

public abstract class AbstractShortestGEDistances
extends java.lang.Object
implements ShortestGEDistances, java.io.Serializable

AbstractShortestGEDistances contains a 2D array of distances between nodes in a directed graph. This class holds a lot of common workhorse methods used by other classes.

Author:
David Walend dfw1@cornell.edu
See Also:
Serialized Form

Field Summary
private  IndexedGEDigraph base
           
private  int[][] distances
           
private  GEPathMeter pathMeter
           
 
Constructor Summary
protected AbstractShortestGEDistances(IndexedGEDigraph ceDigraph, GEPathMeter pathMeter)
           
 
Method Summary
protected  void bfTest()
           
 IndexedGEDigraph getBase()
           
 int getLength(int from, int to)
           
 int getLength(java.lang.Object fromNode, java.lang.Object toNode)
           
 GEPathMeter getPathMeter()
          Return the path meter used to evaluate these shortest paths.
 java.lang.Class getPrincipleInterface()
          Returns the class's principle interface for state comparisons.
protected  void initializeDistances()
           
abstract  void recalculate()
          Rediscover the shortest paths.
protected  void relax(int fromIndex, int throughIndex, int toIndex)
           
protected  int safeLength(int from, int to)
           
 boolean sameStateAs(HasState victim)
          If two HasStates have the same internal state, return true.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

distances

private int[][] distances

pathMeter

private GEPathMeter pathMeter

base

private IndexedGEDigraph base
Constructor Detail

AbstractShortestGEDistances

protected AbstractShortestGEDistances(IndexedGEDigraph ceDigraph,
                                      GEPathMeter pathMeter)
                               throws GENegativeWeightCycleException
Method Detail

bfTest

protected void bfTest()
               throws GENegativeWeightCycleException
GENegativeWeightCycleException

getBase

public IndexedGEDigraph getBase()
Specified by:
getBase in interface ShortestGEDistances

initializeDistances

protected void initializeDistances()

relax

protected void relax(int fromIndex,
                     int throughIndex,
                     int toIndex)

recalculate

public abstract void recalculate()
                          throws GENegativeWeightCycleException
Rediscover the shortest paths.

Specified by:
recalculate in interface ShortestGEDistances
GENegativeWeightCycleException

getPathMeter

public GEPathMeter getPathMeter()
Return the path meter used to evaluate these shortest paths.

Specified by:
getPathMeter in interface ShortestGEDistances

getLength

public int getLength(int from,
                     int to)
Specified by:
getLength in interface ShortestGEDistances

safeLength

protected final int safeLength(int from,
                               int to)

getLength

public int getLength(java.lang.Object fromNode,
                     java.lang.Object toNode)
              throws NodeMissingException
Specified by:
getLength in interface ShortestGEDistances
NodeMissingException

getPrincipleInterface

public java.lang.Class getPrincipleInterface()
Description copied from interface: HasState
Returns the class's principle interface for state comparisons. If two objects have different principle interfaces, they never have the same state.

Specified by:
getPrincipleInterface in interface HasState

sameStateAs

public boolean sameStateAs(HasState victim)
Description copied from interface: HasState
If two HasStates have the same internal state, return true.

For objects with subobjects, Generally this method should only return true if the internal objects are equal. Implement a contentsHaveSameState() method to determine if the contents have the same state.

Specified by:
sameStateAs in interface HasState

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright (c) 2001, 2002, David Walend