sofya.graphs
Class Edge

java.lang.Object
  extended by sofya.graphs.Edge
Direct Known Subclasses:
CFEdge

public class Edge
extends java.lang.Object

An edge is a component of a graph that represents the flow of control from one node to another. Every edge maintains the IDs of its source and sink nodes.

Version:
09/16/2004
Author:
Alex Kinneer
See Also:
Graph, Node

Field Summary
protected  int edgeID
          The edge's ID.
protected  java.lang.String label
          The edge's label.
protected  int predNodeID
          ID of the node from which this edge originates.
protected  int succNodeID
          ID of the node on which this edge is incident.
static Edge[] ZL_ARRAY
          Zero-length edge array useful for specifying array cast types to methods such Graph.getEdges(Node,Node,Edge[]).
 
Constructor Summary
Edge()
          Creates an edge with ID zero, an empty label, and the successor and predecessor nodes set to zero.
Edge(int id, int s, int p, java.lang.String label)
          Creates an edge with the given label, ID, successor, and predecessor nodes.
 
Method Summary
 int getID()
          Gets the ID of this edge.
 java.lang.String getLabel()
          Gets the label for this edge.
 int getPredNodeID()
          Gets the predecessor node of this edge.
 int getSuccNodeID()
          Gets the successor node of this edge.
static void main(java.lang.String[] args)
          Test driver for the Edge class.
 void setID(int id)
          Sets the ID of this edge.
 void setLabel(java.lang.String s)
          Sets the label for this edge.
 void setPredNodeID(int p)
          Sets the predecessor node of this edge.
 void setSuccNodeID(int s)
          Sets the successor node of this edge.
 java.lang.String toString()
          Returns a string representation of this edge in the form:
label: sourceNodeID -> sinkNodeID.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

edgeID

protected int edgeID
The edge's ID.


succNodeID

protected int succNodeID
ID of the node on which this edge is incident.


predNodeID

protected int predNodeID
ID of the node from which this edge originates.


label

protected java.lang.String label
The edge's label.


ZL_ARRAY

public static final Edge[] ZL_ARRAY
Zero-length edge array useful for specifying array cast types to methods such Graph.getEdges(Node,Node,Edge[]).

Constructor Detail

Edge

public Edge()
Creates an edge with ID zero, an empty label, and the successor and predecessor nodes set to zero.


Edge

public Edge(int id,
            int s,
            int p,
            java.lang.String label)
Creates an edge with the given label, ID, successor, and predecessor nodes.

Parameters:
id - ID of the new edge.
s - ID of the new edge's successor node.
p - ID of the new edge's predecessor node.
label - Label to be assigned to the new edge.
Method Detail

setID

public void setID(int id)
Sets the ID of this edge.

Parameters:
id - New ID to assign to this edge.

getID

public int getID()
Gets the ID of this edge.

Returns:
The ID assigned to this edge.

setSuccNodeID

public void setSuccNodeID(int s)
Sets the successor node of this edge.

Parameters:
s - ID of the node that is to be the new successor of this edge.

getSuccNodeID

public int getSuccNodeID()
Gets the successor node of this edge.

Returns:
The ID of the successor node of this edge.

setPredNodeID

public void setPredNodeID(int p)
Sets the predecessor node of this edge.

Parameters:
p - ID of the node that is to be the new predecessor node of this edge.

getPredNodeID

public int getPredNodeID()
Gets the predecessor node of this edge.

Returns:
The ID of the predecessor node of this edge.

setLabel

public void setLabel(java.lang.String s)
Sets the label for this edge.

Assigning version-dependent values to this field should be avoided.

Parameters:
s - New label to be assigned to this edge.

getLabel

public java.lang.String getLabel()
Gets the label for this edge.

Returns:
The label assigned to this edge.

toString

public java.lang.String toString()
Returns a string representation of this edge in the form:
label: sourceNodeID -> sinkNodeID.

If the edge is unlabeled, the special token "(nl)" is used for the label.

Overrides:
toString in class java.lang.Object
Returns:
This edge represented as a string.

main

public static void main(java.lang.String[] args)
Test driver for the Edge class.