|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object sofya.graphs.Node
public class Node
Class to represent a node in a graph. Every node has an ID, a list of predecessors, and a list of of successors.
A node P is a predecessor to this node if there is an edge from P to this node. A node S is a successor to this node if there is an edge from this node to S.
Graph
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface sofya.base.SConstants |
---|
SConstants.BlockLabel, SConstants.BlockObjectType, SConstants.BlockSubType, SConstants.BlockType, SConstants.BranchObjectType, SConstants.BranchType, SConstants.EDObjectType, SConstants.TraceObjectType |
Field Summary | |
---|---|
protected int |
nodeID
The node's unique ID. |
protected java.util.List |
predecessors
Collection of the node's predecessors. |
protected java.util.List |
successors
Collection of the node's successors. |
static Node[] |
ZL_ARRAY
Zero-length node array useful for specifying array cast types to methods such getSuccessors(Node[]) . |
Fields inherited from interface sofya.base.SConstants |
---|
DEFAULT_PORT, INST_COMPATIBLE, INST_OLD_UNSUPPORTED, INST_OPT_NORMAL, INST_OPT_SEQUENCE, SIG_CHKALIVE, SIG_ECHO |
Constructor Summary | |
---|---|
Node()
Creates a new node with ID zero. |
|
Node(int id)
Creates a new node with a given ID. |
Method Summary | |
---|---|
void |
addPredecessor(Node n)
Adds a node to this node's predecessor list. |
void |
addSuccessor(Node n)
Adds a node to this node's successor list. |
int |
getID()
Gets this node's ID. |
int |
getPredecessorCount()
Gets the number of predecessors to this node. |
Node[] |
getPredecessors()
Gets this node's predecessor list. |
Node[] |
getPredecessors(Node[] a)
Gets this node's predecessors in a type-specific array. |
java.util.List |
getPredecessorsList()
Gets this node's predecessors as a java.util.List
(unmodifiable). |
int |
getSuccessorCount()
Gets the number of successors of this node. |
Node[] |
getSuccessors()
Gets this node's successor list. |
Node[] |
getSuccessors(Node[] a)
Gets this node's successors in a type-specific array. |
java.util.List |
getSuccessorsList()
Gets this node's successors as a java.util.List
(unmodifiable). |
static void |
main(java.lang.String[] args)
Test driver for the Node class. |
void |
removePredecessor(Node n)
Removes a node from this node's predecessor list. |
void |
removeSuccessor(Node n)
Removes a node from this node's successor list. |
void |
setID(int n)
Sets this node's ID. |
java.lang.String |
toString()
Returns a string representation of this node, which consists of the node's ID. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected int nodeID
protected java.util.List successors
protected java.util.List predecessors
public static final Node[] ZL_ARRAY
getSuccessors(Node[])
.
Constructor Detail |
---|
public Node()
public Node(int id)
Method Detail |
---|
public void setID(int n)
n
- ID to be assigned to this node.public int getID()
public void addSuccessor(Node n)
n
- Node to be added to the successor list.public void removeSuccessor(Node n)
n
- Node to be removed from the successor list.public Node[] getSuccessors()
public Node[] getSuccessors(Node[] a)
a
- Array which will be used to determine the runtime type
of the array returned by this method.
public java.util.List getSuccessorsList()
java.util.List
(unmodifiable).
public void addPredecessor(Node n)
n
- Node to be added to the predecessor list.public void removePredecessor(Node n)
n
- Node to be removed from the predecessor list.public Node[] getPredecessors()
public Node[] getPredecessors(Node[] a)
a
- Array which will be used to determine the runtime type
of the array returned by this method.
public java.util.List getPredecessorsList()
java.util.List
(unmodifiable).
public int getPredecessorCount()
public int getSuccessorCount()
public java.lang.String toString()
toString
in class java.lang.Object
public static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |