public abstract class AbstractIntegerNodeGraph extends AbstractGraph implements Serializable
Integers
from zero to a specified number (exclusive) and the edges do not
contain user-defined objects. This is mainly useful for
implementing special-case graphs that do not actually need to
explicitly store their structure.
This implementation is simple. Any extension must also be
simple to support on-the-fly Graph.Edge creation. To
fully implement an extension of this class, the programmer must
provide implementations for the following methods:
In addition, it is recommended that the programmer override
degree( node ) (when applicable) since its
default implementation inefficiently depends upon other
iterator-returning methods.
| Modifier and Type | Class and Description |
|---|---|
protected class |
AbstractIntegerNodeGraph.AbstractIntegerEdgeCollection |
protected static class |
AbstractIntegerNodeGraph.EdgeImpl
Protected
Graph.Edge implementation. |
Graph.Edge| Modifier | Constructor and Description |
|---|---|
protected |
AbstractIntegerNodeGraph(int n)
Creates a new
AbstractIntegerNodeGraph. |
| Modifier and Type | Method and Description |
|---|---|
protected int |
checkNode(Object node)
Returns the specified node as a primitive
int
from 0 to the number of nodes in this graph
(exclusive) if the specified node is in this graph. |
boolean |
containsEdge(Graph.Edge edge)
Returns
true if this Graph contains
the specified Graph.Edge. |
boolean |
containsNode(Object node)
Returns
true if this Graph contains
the specified node. |
protected abstract Graph.Edge |
createEdge(int tailIndex,
int headIndex)
If an edge exists between the specified indices, create and
return it.
|
protected abstract Collection |
createEdgeCollection()
Creates the (single) collection of edges for this instance.
|
protected abstract Traverser |
createTraverser(int nodeIndex)
Creates a traverser with no filtering; assumes that the node
index is valid.
|
protected Collection |
edges()
Returns a
Collection view of all the
Graph.Edges in this Graph. |
protected int |
getNodeIndex(Object node)
Returns the specified node as a primitive
int
from 0 to the number of nodes in this graph
(exclusive) if the specified node is in this graph. |
protected int |
getNodeSize()
Returns the number of nodes in this
AbstractIntegerNodeGraph. |
protected Collection |
nodes()
Returns a
Collection view of all the nodes
in this Graph. |
boolean |
removeEdge(Graph.Edge edge)
Throws an
UnsupportedOperationException. |
boolean |
removeNode(Object node)
Throws an
UnsupportedOperationException. |
protected Traverser |
traverser(Object node)
Returns an unfiltered
Traverser over those
Graph.Edges incident to the specified node. |
addEdge, addNode, adjacentNodes, degree, degree, edges, getAdjacentNode, getEdge, getIncidentEdge, getNode, incidentEdges, nodes, traverserprotected AbstractIntegerNodeGraph(int n)
AbstractIntegerNodeGraph.protected final Collection nodes()
AbstractGraphCollection view of all the nodes
in this Graph. This method is only called
by nodes( Predicate ).nodes in class AbstractGraphprotected final Collection edges()
AbstractGraphCollection view of all the
Graph.Edges in this Graph.
This method is only called by edges( Predicate ).edges in class AbstractGraphprotected final Traverser traverser(Object node)
AbstractGraphTraverser over those
Graph.Edges incident to the specified node.
This method is only called by traverser( node, Predicate ).traverser in class AbstractGraphpublic final boolean removeNode(Object node)
UnsupportedOperationException.removeNode in interface GraphremoveNode in class AbstractGraphnode - the node to be removed from this
Graph.true if this Graph contained
node.public final boolean containsNode(Object node)
true if this Graph contains
the specified node.containsNode in interface GraphcontainsNode in class AbstractGraphnode - the node whose presence in this Graph
is to be tested.true if this Graph contains
the specified node.public final boolean removeEdge(Graph.Edge edge)
UnsupportedOperationException.removeEdge in interface GraphremoveEdge in class AbstractGraphedge - the Graph.Edge to be removed from
this Graph.true if this Graph contained
the specified Graph.Edge.public boolean containsEdge(Graph.Edge edge)
true if this Graph contains
the specified Graph.Edge. This implementation
tests the specified edge for equality with the one returned by
createEdge( tailIndex, headIndex ) with
the same tail and head.containsEdge in interface GraphcontainsEdge in class AbstractGraphedge - the Graph.Edge whose presence in this
Graph is to be tested.true if this Graph contains
the specified Graph.Edge.protected final int getNodeSize()
AbstractIntegerNodeGraph.protected final int getNodeIndex(Object node)
int
from 0 to the number of nodes in this graph
(exclusive) if the specified node is in this graph.
Otherwise, returns -1.protected final int checkNode(Object node)
int
from 0 to the number of nodes in this graph
(exclusive) if the specified node is in this graph.
Otherwise, throws an NoSuchNodeException.protected abstract Graph.Edge createEdge(int tailIndex, int headIndex)
null. The indices are
assumed to represent valid nodes for this Graph.protected abstract Collection createEdgeCollection()
protected abstract Traverser createTraverser(int nodeIndex)
See the Plexus project home, hosted by SourceForge.
Copyright ? 1994-2006, by Phoenix Software Technologists, Inc. and others. All Rights Reserved. Use is subject to license terms.