algo
Class Graph

java.lang.Object
  extended by algo.Graph
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
PlaneGraph

public class Graph
extends java.lang.Object
implements java.io.Serializable

A Graph for an TSP Problem.

Author:
Heinz Kredel.
See Also:
Serialized Form

Field Summary
protected  double[][] g
           
(package private) static double INFINITY
           
 
Constructor Summary
Graph(int n)
          Constructs an unconnected graph of given size.
 
Method Summary
 void connect(int i, int j, double d)
          Connect two nodes by defining a distance.
 double distance(int i, int j)
          Get the distance between two nodes.
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

g

protected double[][] g

INFINITY

static final double INFINITY
See Also:
Constant Field Values
Constructor Detail

Graph

public Graph(int n)
Constructs an unconnected graph of given size.

Parameters:
n - size of the graph.
Method Detail

connect

public void connect(int i,
                    int j,
                    double d)
Connect two nodes by defining a distance.

Parameters:
i - node number.
j - node number.
d - distance between the two nodes.

distance

public double distance(int i,
                       int j)
Get the distance between two nodes.

Parameters:
i - node number.
j - node number.
Returns:
distance between the two nodes.

size

public int size()
Returns:
size of the graph.