com.phoenixst.plexus.examples
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.
Since: 1.0
Version: $Revision: 1.8 $
Nested Class Summary | |
---|---|
protected abstract class | AbstractIntegerNodeGraph.AbstractIntegerEdgeCollection |
protected static class | AbstractIntegerNodeGraph.EdgeImpl
Protected Graph.Edge implementation. |
Constructor Summary | |
---|---|
protected | AbstractIntegerNodeGraph(int n)
Creates a new AbstractIntegerNodeGraph . |
Method Summary | |
---|---|
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() |
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() |
boolean | removeEdge(Graph.Edge edge)
Throws an UnsupportedOperationException . |
boolean | removeNode(Object node)
Throws an UnsupportedOperationException . |
protected Traverser | traverser(Object node) |
AbstractIntegerNodeGraph
.int
from 0
to the number of nodes in this graph
(exclusive) if the specified node is in this graph.
Otherwise, throws an NoSuchNodeException
.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.true
if this Graph
contains
the specified node.null
. The indices are
assumed to represent valid nodes for this Graph
.int
from 0
to the number of nodes in this graph
(exclusive) if the specified node is in this graph.
Otherwise, returns -1
.AbstractIntegerNodeGraph
.UnsupportedOperationException
.UnsupportedOperationException
.