javax.imageio.spi
class: DigraphNode [javadoc |
source]
java.lang.Object
javax.imageio.spi.DigraphNode
All Implemented Interfaces:
Cloneable, java$io$Serializable
A node in a directed graph. In addition to an arbitrary
Object containing user data associated with the node,
each node maintains a
Sets of nodes which are pointed
to by the current node (available from
getOutNodes).
The in-degree of the node (that is, number of nodes that point to
the current node) may be queried.
| Field Summary |
|---|
| protected Object | data | The data associated with this node. |
| protected Set | outNodes | A Set of neighboring nodes pointed to by this
node. |
| protected int | inDegree | The in-degree of the node. |
| Methods from java.lang.Object: |
|---|
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method from javax.imageio.spi.DigraphNode Detail: |
public boolean addEdge(DigraphNode node) {
if (outNodes.contains(node)) {
return false;
}
outNodes.add(node);
node.inNodes.add(this);
node.incrementInDegree();
return true;
}
Adds a directed edge to the graph. The outNodes list of this
node is updated and the in-degree of the other node is incremented. |
public void dispose() {
Object[] inNodesArray = inNodes.toArray();
for(int i=0; i< inNodesArray.length; i++) {
DigraphNode node = (DigraphNode) inNodesArray[i];
node.removeEdge(this);
}
Object[] outNodesArray = outNodes.toArray();
for(int i=0; i< outNodesArray.length; i++) {
DigraphNode node = (DigraphNode) outNodesArray[i];
removeEdge(node);
}
}
Removes this node from the graph, updating neighboring nodes
appropriately. |
public Object getData() {
return data;
}
Returns the Object referenced by this node. |
public int getInDegree() {
return inDegree;
}
Returns the in-degree of this node. |
public Iterator getOutNodes() {
return outNodes.iterator();
}
Returns an Iterator containing the nodes pointed
to by this node. |
public boolean hasEdge(DigraphNode node) {
return outNodes.contains(node);
}
Returns true if an edge exists between this node
and the given node. |
public boolean removeEdge(DigraphNode node) {
if (!outNodes.contains(node)) {
return false;
}
outNodes.remove(node);
node.inNodes.remove(this);
node.decrementInDegree();
return true;
}
Removes a directed edge from the graph. The outNodes list of this
node is updated and the in-degree of the other node is decremented. |