de.jstacs.algorithms.graphs
Class Edge

java.lang.Object
  extended by de.jstacs.algorithms.graphs.Edge
All Implemented Interfaces:
Cloneable, Comparable<Edge>

public class Edge
extends Object
implements Comparable<Edge>, Cloneable

This class is a representation of a weighted edge.

Author:
Jens Keilwagen

Field Summary
protected  int source
          The source node.
protected  int target
          The target node.
protected  double weight
          The weight of the edge.
 
Constructor Summary
Edge(int s, int t, double w)
          Creates a new weighted edge.
 
Method Summary
 Edge clone()
           
 int compareTo(Edge e)
           
 int getEndNode()
          Returns the end node of the edge.
 int getStartNode()
          Returns the start node of the edge.
 double getWeight()
          Returns the weight of the edge.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

source

protected int source
The source node.


target

protected int target
The target node.


weight

protected double weight
The weight of the edge.

Constructor Detail

Edge

public Edge(int s,
            int t,
            double w)
     throws IllegalArgumentException
Creates a new weighted edge.

Parameters:
s - the start node
t - the target (=end) node
w - the weight of the edge
Throws:
IllegalArgumentException - if the names of the nodes are less than 0
Method Detail

getStartNode

public int getStartNode()
Returns the start node of the edge.

Returns:
the start node of the edge

getEndNode

public int getEndNode()
Returns the end node of the edge.

Returns:
the end node of the edge

getWeight

public double getWeight()
Returns the weight of the edge.

Returns:
the weight of the edge

toString

public String toString()
Overrides:
toString in class Object

compareTo

public int compareTo(Edge e)
              throws ClassCastException
Specified by:
compareTo in interface Comparable<Edge>
Throws:
ClassCastException

clone

public Edge clone()
Overrides:
clone in class Object