Class PathGenerator

java.lang.Object
  |
  +--PathGenerator
All Implemented Interfaces:
javax.swing.event.ChangeListener, java.util.EventListener

public class PathGenerator
extends java.lang.Object
implements javax.swing.event.ChangeListener

Class that generates all shortest paths for a given Graph. The shortest paths can be made cyclic canonical for the purpose of cycle generation. The PathGenerator object is always in sync with the Graph object by using the ChangeListener to regenerate Paths on demand.

Author:
Dries.VanDyck@rug.ac.be
See Also:
Graph, Path, Cycle

Constructor Summary
PathGenerator(Graph g)
          Constructs a new PathGenerator for the graph g.
 
Method Summary
 int diameter()
          Returns the diameter of the Graph.
 int distance(int i, int j)
          Returns the distance between the nodes i and j.
static void main(java.lang.String[] args)
          Program which prints all shortest paths (not cyclic canonical) to the screen of the YutsisGraph specified by the first argument.
 void makeCanonical()
          Only the Path's wich passes nodes bigger than the start node will remain.
 java.util.ArrayList paths(int i, int j)
          Returns a vector of shortest paths between i and j
 void stateChanged(javax.swing.event.ChangeEvent e)
          Implementation of the ChangeListener interface.
 java.lang.String toString()
          Returns a String representation of this PathGenerator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PathGenerator

public PathGenerator(Graph g)
Constructs a new PathGenerator for the graph g.

Parameters:
g - the Graph for which shortest paths have to be generated
See Also:
Graph
Method Detail

paths

public java.util.ArrayList paths(int i,
                                 int j)
Returns a vector of shortest paths between i and j

Parameters:
i - first node for which all Path's have to be returned
j - second node for which all Path's have to be returned
See Also:
Path

distance

public int distance(int i,
                    int j)
Returns the distance between the nodes i and j. A distance equal to the Graph's order (original nr of nodes) has to be regarded as infinity.

Parameters:
i - first node for which the distance has to be returned
j - second node for which the distance has to be returned
Returns:
the distance between the specified nodes
See Also:
Graph

stateChanged

public void stateChanged(javax.swing.event.ChangeEvent e)
Implementation of the ChangeListener interface.

Specified by:
stateChanged in interface javax.swing.event.ChangeListener

makeCanonical

public void makeCanonical()
Only the Path's wich passes nodes bigger than the start node will remain. A combination of such two paths uniquely defines a Cycle: P(i,k) + P'(i,k) for an even cycle or P(i,x) + P(i,y) + (x,y).

See Also:
Path, Cycle

diameter

public int diameter()
Returns the diameter of the Graph.

Returns:
the diameter of the Graph
See Also:
Graph

toString

public java.lang.String toString()
Returns a String representation of this PathGenerator.

Overrides:
toString in class java.lang.Object
Returns:
a String representation of this PathGenerator

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
Program which prints all shortest paths (not cyclic canonical) to the screen of the YutsisGraph specified by the first argument. When ran without arguments it prints a "usage" to System.err. However this class can be used with each object implementing the Graph interface, this main function (and thus the program) only works on YutsisGraph's.

java.io.IOException
See Also:
Graph, YutsisGraph