nct.graph
Class BasicEdge<NodeType extends java.lang.Comparable<? super NodeType>,WeightType extends java.lang.Comparable<? super WeightType>>

java.lang.Object
  extended by nct.graph.BasicEdge<NodeType,WeightType>
All Implemented Interfaces:
java.lang.Comparable<Edge<NodeType,WeightType>>, Edge<NodeType,WeightType>

public class BasicEdge<NodeType extends java.lang.Comparable<? super NodeType>,WeightType extends java.lang.Comparable<? super WeightType>>
extends java.lang.Object
implements Edge<NodeType,WeightType>

A generic implementation of the Edge interface.


Field Summary
protected  java.lang.String description
          The edge description.
protected  NodeType sourceNode
          The source node of the edge.
protected  NodeType targetNode
          The target node of the edge.
protected  WeightType weight
          The edge weight.
 
Constructor Summary
BasicEdge(NodeType sourceNode, NodeType targetNode, WeightType weight)
           
BasicEdge(NodeType sourceNode, NodeType targetNode, WeightType weight, java.lang.String desc)
           
 
Method Summary
 int compareTo(Edge<NodeType,WeightType> e)
          First compares whether the source and target nodes are the same and if so assumes the edge is the same.
 boolean equals(java.lang.Object o)
           
 java.lang.String getDescription()
           
 NodeType getSourceNode()
           
 NodeType getTargetNode()
           
 WeightType getWeight()
           
 int hashCode()
           
 void setDescription(java.lang.String desc)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

sourceNode

protected NodeType extends java.lang.Comparable<? super NodeType> sourceNode
The source node of the edge.


targetNode

protected NodeType extends java.lang.Comparable<? super NodeType> targetNode
The target node of the edge.


weight

protected WeightType extends java.lang.Comparable<? super WeightType> weight
The edge weight.


description

protected java.lang.String description
The edge description.

Constructor Detail

BasicEdge

public BasicEdge(NodeType sourceNode,
                 NodeType targetNode,
                 WeightType weight,
                 java.lang.String desc)
Parameters:
sourceNode - The source node of the edge.
targetNode - The target node of the edge.
weight - The edge weight.
desc - The edge description.

BasicEdge

public BasicEdge(NodeType sourceNode,
                 NodeType targetNode,
                 WeightType weight)
Parameters:
sourceNode - The source node of the edge.
targetNode - The target node of the edge.
weight - The edge weight.
Method Detail

getWeight

public WeightType getWeight()
Specified by:
getWeight in interface Edge<NodeType extends java.lang.Comparable<? super NodeType>,WeightType extends java.lang.Comparable<? super WeightType>>
Returns:
The weight of this edge.

setDescription

public void setDescription(java.lang.String desc)
Specified by:
setDescription in interface Edge<NodeType extends java.lang.Comparable<? super NodeType>,WeightType extends java.lang.Comparable<? super WeightType>>
Parameters:
desc - The description of the edge.

getDescription

public java.lang.String getDescription()
Specified by:
getDescription in interface Edge<NodeType extends java.lang.Comparable<? super NodeType>,WeightType extends java.lang.Comparable<? super WeightType>>
Returns:
The description of the edge.

compareTo

public int compareTo(Edge<NodeType,WeightType> e)
First compares whether the source and target nodes are the same and if so assumes the edge is the same. If not, then compares the edge weights.

Specified by:
compareTo in interface java.lang.Comparable<Edge<NodeType extends java.lang.Comparable<? super NodeType>,WeightType extends java.lang.Comparable<? super WeightType>>>
Parameters:
e - The other edge to compare against this one.

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object
Parameters:
o - The edge to compare against this one.
Returns:
True if nodes, description, and weigt are all equal.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
Returns:
A unique hashcode of this instantiation.

getSourceNode

public NodeType getSourceNode()
Specified by:
getSourceNode in interface Edge<NodeType extends java.lang.Comparable<? super NodeType>,WeightType extends java.lang.Comparable<? super WeightType>>
Returns:
The source node of this edge.

getTargetNode

public NodeType getTargetNode()
Specified by:
getTargetNode in interface Edge<NodeType extends java.lang.Comparable<? super NodeType>,WeightType extends java.lang.Comparable<? super WeightType>>
Returns:
The target node of this edge.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
A string listing all elements of the edge.