net.walend.measured
Class AbstractShortestCEDistances

java.lang.Object
  |
  +--net.walend.measured.AbstractShortestCEDistances
All Implemented Interfaces:
HasState, java.io.Serializable, ShortestCEDistances
Direct Known Subclasses:
DijkstraShortestCEDistances, FloydWarshallShortestCEDistances

public abstract class AbstractShortestCEDistances
extends java.lang.Object
implements ShortestCEDistances, java.io.Serializable

AbstractShortestCEDistances 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  IndexedCEDigraph base
           
private  int[][] distances
           
private  CEPathMeter pathMeter
           
 
Constructor Summary
protected AbstractShortestCEDistances(IndexedCEDigraph ceDigraph, CEPathMeter pathMeter)
           
 
Method Summary
protected  void bfTest()
           
 IndexedCEDigraph getBase()
           
 int getLength(int from, int to)
           
 int getLength(java.lang.Object fromNode, java.lang.Object toNode)
           
 CEPathMeter 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 CEPathMeter pathMeter

base

private IndexedCEDigraph base
Constructor Detail

AbstractShortestCEDistances

protected AbstractShortestCEDistances(IndexedCEDigraph ceDigraph,
                                      CEPathMeter pathMeter)
                               throws CENegativeWeightCycleException
Method Detail

bfTest

protected void bfTest()
               throws CENegativeWeightCycleException
CENegativeWeightCycleException

getBase

public IndexedCEDigraph getBase()
Specified by:
getBase in interface ShortestCEDistances

initializeDistances

protected void initializeDistances()

relax

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

recalculate

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

Specified by:
recalculate in interface ShortestCEDistances
CENegativeWeightCycleException

getPathMeter

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

Specified by:
getPathMeter in interface ShortestCEDistances

getLength

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

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 ShortestCEDistances
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