structure5
Class ComparableEdge<V,E extends Comparable<E>>

java.lang.Object
  extended by structure5.Edge<V,E>
      extended by structure5.ComparableEdge<V,E>
All Implemented Interfaces:
Comparable<ComparableEdge<V,E>>

public class ComparableEdge<V,E extends Comparable<E>>
extends Edge<V,E>
implements Comparable<ComparableEdge<V,E>>

A class implementing common edge type among graphs. This class supports both directed and undirected edges. Edge may also have visited flags set and cleared. ComparableEdge differs from edge, however, in that it requires that its lable be of a comparable type.

Typical usage:

     Graph g = new GraphListDirected();
     g.add("harry");
     g.add("sally");
     g.addEdge("harry","sally","friendly");
     ComparableEdge e = new ComparableEdge(g.getEdge("harry","sally"));
     Comparable label = e.label();
     Vertex source = e.here();
     Vertex destination = e.there();
     ComparableEdge e2 = e;
     if(e.compareTo(e2) == 0){
         e.visit();
         e.reset();
     }
     ...
 

See Also:
structure.Graph

Constructor Summary
ComparableEdge(Edge<V,E> e)
          Construct a (possibly directed) edge between two labeled vertices.
ComparableEdge(V vtx1, V vtx2, E label, boolean directed)
          Construct a (possibly directed) edge between two labeled vertices.
 
Method Summary
 int compareTo(ComparableEdge<V,E> other)
          Compare edge, based on labels.
 String toString()
          Construct a string representation of edge.
 
Methods inherited from class structure5.Edge
equals, hashCode, here, isDirected, isVisited, label, reset, setLabel, there, visit
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ComparableEdge

public ComparableEdge(V vtx1,
                      V vtx2,
                      E label,
                      boolean directed)
Construct a (possibly directed) edge between two labeled vertices. When edge is directed, vtx1 specifies source. When undirected, order of vertices is unimportant. Label on edge is any type, and may be null. Edge is initially unvisited.

Parameters:
vtx1 - The label of a vertex (source if directed).
vtx2 - The label of another vertex (destination if directed).
label - The label associated with the edge.
directed - True iff this edge is directed.

ComparableEdge

public ComparableEdge(Edge<V,E> e)
Construct a (possibly directed) edge between two labeled vertices. When edge is directed, vtx1 specifies source. When undirected, order of vertices is unimportant. Label on edge is any type, and may be null. Edge is initially unvisited.

Parameters:
e - The edge to be used as the basis for a comparable edge
Method Detail

compareTo

public int compareTo(ComparableEdge<V,E> other)
Compare edge, based on labels.

Specified by:
compareTo in interface Comparable<ComparableEdge<V,E extends Comparable<E>>>

toString

public String toString()
Construct a string representation of edge.

Overrides:
toString in class Edge<V,E extends Comparable<E>>
Returns:
String representing edge.