org.gersteinlab.tyna.core.graph
Class Edge

java.lang.Object
  extended by org.gersteinlab.tyna.core.graph.Edge
All Implemented Interfaces:
java.io.Serializable

public class Edge
extends java.lang.Object
implements java.io.Serializable

        This class represents an edge in a graph. Edge weight is the only
        default attribute. Other attributes can be accessed through the
        attribute methods.

        By convention, if the edge is directed, it is from node1 to node2.

        Whether two edges are the same depending on the graph type. It is not
        recommended to compare different edges outside the Graph classes, unless
        the comparator is very sure about the correct way to perform the
        comparisons. Methods such as Graph.containsEdge() should be used
        instead.
        

Version:
1.0 (September 20, 2005) Change History: 1.0 - Initial version
Author:
Kevin Yuk-Lap Yip
See Also:
Serialized Form

Field Summary
protected  java.util.Map attrs
          Other attributes of the edge (can be null).
protected  Node node1
          The first node of the edge.
protected  Node node2
          The second node of the edge.
protected  double weight
          The weight of the edge.
 
Constructor Summary
Edge(Node node1, Node node2, double weight, java.util.Map attrs)
          Constructor: creates an edge between the two nodes, with the input attributes.
 
Method Summary
 java.lang.Object getAttr(java.lang.Object attrName)
          Get the (possibly null) value of an attribute of the edge.
 java.util.Map getAttrs()
          Get the (possibly null) attribute map of the node.
 Node getNode1()
          Get the first node of the edge.
 Node getNode2()
          Get the second node of the edge.
 double getWeight()
          Get the edge weight.
 void removeAttr(java.lang.Object attrName)
          Remove the value of an attribute from the node.
 void setAttr(java.lang.Object attrName, java.lang.Object attrVal)
          Set the value of an attribute of the edge.
 void setWeight(double weight)
          Set the edge weight.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

node1

protected Node node1
The first node of the edge.


node2

protected Node node2
The second node of the edge.


weight

protected double weight
The weight of the edge.


attrs

protected java.util.Map attrs
Other attributes of the edge (can be null).

Constructor Detail

Edge

public Edge(Node node1,
            Node node2,
            double weight,
            java.util.Map attrs)
Constructor: creates an edge between the two nodes, with the input attributes. For a directed graph, the edge is from node1 to node2. A copy of attrs, rather than the original object, is being stored.

Parameters:
node1 - The first node
node2 - The second node
weight - The edge weight
attrs - Edge attributes
Method Detail

getNode1

public Node getNode1()
Get the first node of the edge.

Returns:
The first node

getNode2

public Node getNode2()
Get the second node of the edge.

Returns:
The second node

getWeight

public double getWeight()
Get the edge weight.

Returns:
The edge weight

setWeight

public void setWeight(double weight)
Set the edge weight.

Parameters:
weight - The edge weight

getAttr

public java.lang.Object getAttr(java.lang.Object attrName)
Get the (possibly null) value of an attribute of the edge.

Parameters:
attrName - The name of the attribute
Returns:
The value of the attribute

getAttrs

public java.util.Map getAttrs()
Get the (possibly null) attribute map of the node. A copy of the stored map is returned.

Returns:
The attribute map

setAttr

public void setAttr(java.lang.Object attrName,
                    java.lang.Object attrVal)
Set the value of an attribute of the edge.

Parameters:
attrName - The name of the attribute
attrVal - The value of the attribute

removeAttr

public void removeAttr(java.lang.Object attrName)
Remove the value of an attribute from the node.

Parameters:
attrName - The name of the attribute