algo
Class PathByteArray

java.lang.Object
  extended by algo.PathByteArray
All Implemented Interfaces:
Path, java.io.Serializable, java.lang.Cloneable

public final class PathByteArray
extends java.lang.Object
implements Path, java.io.Serializable

A Path in a graph implementd as arrays of bytes.

Author:
Heinz Kredel.
See Also:
Serialized Form

Field Summary
 double cost
           
 Graph graph
           
 int length
           
 int maxsize
           
 byte[] unused
           
 byte[] used
           
 
Constructor Summary
PathByteArray(Graph g, byte[] u, byte[] uu, double c)
           
PathByteArray(Graph g, byte[] u, int pos, byte[] uu, double c)
           
 
Method Summary
 java.lang.Object clone()
          Clone / copy this path.
 Path copyMax()
          Clone / copy this path, but allocate full length used array.
 double cost()
           
protected static double cost(double c)
          Dummy function.
static PathByteArray emptyPath(Graph g)
          Empty path, all n points unused.
 int length()
           
 int maxsize()
           
 Path nextPath(int pos)
          Get next possible path reusing used array.
 Path[] nextPaths()
          Get array of next possible paths.
static PathByteArray onePath(Graph g)
          One path.
static PathByteArray standardPath(Graph g)
          Standard path from point 0 to point n-1 to 0.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

graph

public final Graph graph

used

public final byte[] used

unused

public final byte[] unused

cost

public final double cost

maxsize

public final int maxsize

length

public final int length
Constructor Detail

PathByteArray

public PathByteArray(Graph g,
                     byte[] u,
                     byte[] uu,
                     double c)
Parameters:
g - the graph.
u - used points.
uu - unused points.
c - cost of this path.

PathByteArray

public PathByteArray(Graph g,
                     byte[] u,
                     int pos,
                     byte[] uu,
                     double c)
Parameters:
g - the graph.
u - used points.
pos - position of last used point in path, e.g. length.
uu - unused points.
c - cost of this path.
Method Detail

clone

public java.lang.Object clone()
Clone / copy this path.

Specified by:
clone in interface Path
Overrides:
clone in class java.lang.Object
See Also:
Object.clone()

cost

public double cost()
Specified by:
cost in interface Path
Returns:
cost of this path.

length

public int length()
Specified by:
length in interface Path
Returns:
length of this path.

maxsize

public int maxsize()
Specified by:
maxsize in interface Path
Returns:
maxsize of this path.

emptyPath

public static PathByteArray emptyPath(Graph g)
Empty path, all n points unused.

Parameters:
g - the graph.
Returns:
a new empty path.

onePath

public static PathByteArray onePath(Graph g)
One path. One point used and other n-1 points unused.

Parameters:
g - the graph.
Returns:
a new path of one point.

standardPath

public static PathByteArray standardPath(Graph g)
Standard path from point 0 to point n-1 to 0.

Parameters:
g - the graph.
Returns:
a new closed path.

copyMax

public Path copyMax()
Clone / copy this path, but allocate full length used array.

Specified by:
copyMax in interface Path
Returns:
a copy of this with maximal used array.

nextPath

public Path nextPath(int pos)
Get next possible path reusing used array. New path shares used array, so do not use in threads.

Specified by:
nextPath in interface Path
Parameters:
pos - position of last valid point in used array.
Returns:
next path.

nextPaths

public Path[] nextPaths()
Get array of next possible paths.

Specified by:
nextPaths in interface Path
Returns:
all possible path starting with this.

toString

public java.lang.String toString()
Specified by:
toString in interface Path
Overrides:
toString in class java.lang.Object

cost

protected static double cost(double c)
Dummy function. Used to increase computing load or to define different traveling costs.

Parameters:
c - actual cost.
Returns:
new cost (most likely equal to c).