All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Class structure.Edge

java.lang.Object
    |
    +----structure.Edge

public class Edge
extends Object
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.

See Also:
Graph

Constructor Index

 o Edge(Object, Object, Object, boolean)
Construct a (possibly directed) edge between two labeled vertices.

Method Index

 o equals(Object)
Test for equality of edges.
 o hashCode()
Returns hashcode associated with edge.
 o here()
Returns the first vertex (or source if directed).
 o isDirected()
Check to see if edge is directed.
 o isVisited()
Check to see if edge has been visited.
 o label()
Get label associated with edge.
 o reset()
Clear the visited flag associated with edge.
 o setLabel(Object)
Sets the label associated with the edge.
 o there()
Returns the second vertex (or source if undirected).
 o toString()
Construct a string representation of edge.
 o visit()
Test and set visited flag on vertex.

Constructors

 o Edge
public Edge(Object vtx1,
            Object vtx2,
            Object 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.

Postcondition:
edge associates vtx1 and vtx2. labeled with label. directed if "directed" set true

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.

Methods

 o here
public Object here()
Returns the first vertex (or source if directed).

Postcondition:
returns first node in edge

Returns:
A vertex; if directed, the source.
 o there
public Object there()
Returns the second vertex (or source if undirected).

Postcondition:
returns second node in edge

Returns:
A vertex; if directed, the destination.
 o setLabel
public void setLabel(Object label)
Sets the label associated with the edge. May be null.

Postcondition:
sets label of this edge to label

Parameters:
label - Any object to label edge, or null.
 o label
public Object label()
Get label associated with edge.

Postcondition:
returns label associated with this edge

Returns:
The label found on the edge.
 o visit
public boolean visit()
Test and set visited flag on vertex.

Postcondition:
visits edge, returns whether previously visited

Returns:
True iff edge was visited previously.
 o isVisited
public boolean isVisited()
Check to see if edge has been visited.

Postcondition:
returns true iff edge has been visited

Returns:
True iff the edge has been visited.
 o isDirected
public boolean isDirected()
Check to see if edge is directed.

Postcondition:
returns true iff edge is directed.

Returns:
True iff the edge has been visited.
 o reset
public void reset()
Clear the visited flag associated with edge.

Postcondition:
resets edge's visited flag to initial state

 o hashCode
public int hashCode()
Returns hashcode associated with edge.

Postcondition:
returns suitable hashcode.

Returns:
An integer code suitable for hashing.
Overrides:
hashCode in class Object
 o equals
public boolean equals(Object o)
Test for equality of edges. Undirected edges are equal if they connect the same vertices. Directed edges must have same direction.

Postcondition:
returns true iff edges connect same vertices

Parameters:
o - The other edge.
Returns:
True iff this edge is equal to other edge.
Overrides:
equals in class Object
 o toString
public String toString()
Construct a string representation of edge.

Postcondition:
returns string representation of edge

Returns:
String representing edge.
Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index