|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.gersteinlab.tyna.core.graph.Node
This class represents a node in a graph. Node ID is the only defined attribute. It has to be a non-null unique identifier. Other attributes such as node label (if not unique) and node color can be accessed through the attribute get-setters. Subclasses can be defined for node types that contain additional attributes, if that is more convenient than using the attribute get-setters. Edges are defined in graphs, the information is not stored in this class. The ID is to be assigned at object instantiation time only, and should not to be changed since it affects hashCode(), equals(), etc. Two nodes are the same if and only if they refer to the same object, or if they have the same non-null ID. hashCode() and equals() are defined in a way that both order-based structures (e.g. TreeSet) and hash-based structures (e.g. HashSet) can be used.
| Field Summary | |
protected java.util.Map |
attrs
The (possibly null) other attributes of the node. |
protected java.lang.Object |
id
The ID of the node. |
| Constructor Summary | |
Node()
Default constructor: creates a node with no ID or attributes. |
|
Node(java.lang.Object id,
java.util.Map attrs)
Constructor: creates a node with an ID and/or attributes. |
|
| Method Summary | |
int |
compareTo(java.lang.Object o)
|
boolean |
equals(java.lang.Object o)
|
java.lang.Object |
getAttr(java.lang.Object attrName)
Get the (possibly null) value of an attribute of the node. |
java.util.Map |
getAttrs()
Get the (possibly null) attribute map of the node. |
java.lang.Object |
getId()
Get the ID of the node. |
int |
hashCode()
|
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 node. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected java.lang.Object id
protected java.util.Map attrs
| Constructor Detail |
public Node()
public Node(java.lang.Object id,
java.util.Map attrs)
id - The node IDattrs - Node attributes| Method Detail |
public int compareTo(java.lang.Object o)
compareTo in interface java.lang.ComparableComparable.compareTo(Object)public boolean equals(java.lang.Object o)
Object.equals(Object)public int hashCode()
Object.hashCode()public java.lang.Object getId()
public java.lang.Object getAttr(java.lang.Object attrName)
attrName - The name of the attribute
public java.util.Map getAttrs()
public void setAttr(java.lang.Object attrName,
java.lang.Object attrVal)
attrName - The name of the attributeattrVal - The value of the attributepublic void removeAttr(java.lang.Object attrName)
attrName - The name of the attributepublic java.lang.String toString()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||