Plexus v0.13.1

com.phoenixst.plexus.util
Class SingletonGraph

java.lang.Object
  extended by com.phoenixst.plexus.util.SingletonGraph
All Implemented Interfaces:
Graph, Serializable

public class SingletonGraph
extends Object
implements Graph, Serializable

An unmodifiable Graph which contains a single node and no edges.

Since:
1.0
Version:
$Revision: 1.22 $
Author:
Ray A. Conner
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.phoenixst.plexus.Graph
Graph.Edge
 
Constructor Summary
SingletonGraph(Object node)
          Creates a new SingletonGraph.
 
Method Summary
 Graph.Edge addEdge(Object object, Object tail, Object head, boolean isDirected)
          Throws an UnsupportedOperationException.
 boolean addNode(Object node)
          Throws an UnsupportedOperationException.
 Collection adjacentNodes(Object node, org.apache.commons.collections.Predicate traverserPredicate)
          Returns an empty collection.
 boolean containsEdge(Graph.Edge edge)
          Returns false.
 boolean containsNode(Object node)
          Returns true if this Graph contains the specified node.
 int degree(Object node)
          Returns the degree of node, defined as the number of edges incident on node, with self-loops counted twice.
 int degree(Object node, org.apache.commons.collections.Predicate traverserPredicate)
          Returns the degree of node for which the specified Predicate is satisfied, defined as the number of edges incident on node that pass the predicate, with self-loops counted only once.
 Collection edges(org.apache.commons.collections.Predicate edgePredicate)
          Returns an empty collection.
 Object getAdjacentNode(Object node, org.apache.commons.collections.Predicate traverserPredicate)
          Returns a node adjacent to the specified node for which the specified Predicate is satisfied.
 Graph.Edge getEdge(org.apache.commons.collections.Predicate edgePredicate)
          Returns null.
 Graph.Edge getIncidentEdge(Object node, org.apache.commons.collections.Predicate traverserPredicate)
          Returns a Graph.Edge incident on the specified node for which the specified Predicate is satisfied.
 Object getNode(org.apache.commons.collections.Predicate nodePredicate)
          Returns a node from this Graph that satisfies the specified predicate, or null if no such node exists.
 Collection incidentEdges(Object node, org.apache.commons.collections.Predicate traverserPredicate)
          Returns an empty collection.
 Collection nodes(org.apache.commons.collections.Predicate nodePredicate)
          Returns the nodes from this Graph that satisfy the specified predicate.
 boolean removeEdge(Graph.Edge edge)
          Throws an UnsupportedOperationException.
 boolean removeNode(Object node)
          Throws an UnsupportedOperationException.
 Traverser traverser(Object node, org.apache.commons.collections.Predicate traverserPredicate)
          Returns a Traverser from node to all adjacent nodes for which the specified Predicate is satisfied.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SingletonGraph

public SingletonGraph(Object node)
Creates a new SingletonGraph.

Method Detail

addNode

public boolean addNode(Object node)
Throws an UnsupportedOperationException.

Specified by:
addNode in interface Graph
Parameters:
node - the node to be added to this Graph.
Returns:
true if this Graph changed as a result of the call, false if this Graph already contains the specified node.

removeNode

public boolean removeNode(Object node)
Throws an UnsupportedOperationException.

Specified by:
removeNode in interface Graph
Parameters:
node - the node to be removed from this Graph.
Returns:
true if this Graph contained node.

containsNode

public boolean containsNode(Object node)
Description copied from interface: Graph
Returns true if this Graph contains the specified node.

Specified by:
containsNode in interface Graph
Parameters:
node - the node whose presence in this Graph is to be tested.
Returns:
true if this Graph contains the specified node.

addEdge

public Graph.Edge addEdge(Object object,
                          Object tail,
                          Object head,
                          boolean isDirected)
Throws an UnsupportedOperationException.

Specified by:
addEdge in interface Graph
Parameters:
object - the user-defined object to be contained in the new edge.
tail - the first endpoint of the new edge.
head - the second endpoint of the new edge.
isDirected - whether the new edge is directed.
Returns:
the newly created Graph.Edge if this Graph changed as a result of the call, null if this Graph does not allow duplicate edges and already contains the specified edge.

removeEdge

public boolean removeEdge(Graph.Edge edge)
Throws an UnsupportedOperationException.

Specified by:
removeEdge in interface Graph
Parameters:
edge - the Graph.Edge to be removed from this Graph.
Returns:
true if this Graph contained the specified Graph.Edge.

containsEdge

public boolean containsEdge(Graph.Edge edge)
Returns false.

Specified by:
containsEdge in interface Graph
Parameters:
edge - the Graph.Edge whose presence in this Graph is to be tested.
Returns:
true if this Graph contains the specified Graph.Edge.

degree

public int degree(Object node)
Description copied from interface: Graph
Returns the degree of node, defined as the number of edges incident on node, with self-loops counted twice. If this node has more than Integer.MAX_VALUE incident edges, returns Integer.MAX_VALUE.

Specified by:
degree in interface Graph
Parameters:
node - return the degree of this node.
Returns:
the degree of node.

degree

public int degree(Object node,
                  org.apache.commons.collections.Predicate traverserPredicate)
Description copied from interface: Graph
Returns the degree of node for which the specified Predicate is satisfied, defined as the number of edges incident on node that pass the predicate, with self-loops counted only once. The argument to the Predicate.evaluate() method is expected to be an OrderedPair. The first element of the OrderedPair is the specified node, the second is the Graph.Edge. If this node has more than Integer.MAX_VALUE such edges, returns Integer.MAX_VALUE.

Specified by:
degree in interface Graph
Parameters:
node - return the degree of this node for which the specified predicate is satisfied.
traverserPredicate - the predicate which the counted Graph.Edges must satisfy.
Returns:
the degree of node for which the specified predicate is satisfied.

nodes

public Collection nodes(org.apache.commons.collections.Predicate nodePredicate)
Description copied from interface: Graph
Returns the nodes from this Graph that satisfy the specified predicate.

Specified by:
nodes in interface Graph
Parameters:
nodePredicate - the predicate which the returned nodes must satisfy.
Returns:
the nodes from this Graph that satisfy the specified predicate.

edges

public Collection edges(org.apache.commons.collections.Predicate edgePredicate)
Returns an empty collection.

Specified by:
edges in interface Graph
Parameters:
edgePredicate - the predicate which the returned Graph.Edges must satisfy.
Returns:
the Graph.Edges from this Graph that satisfy the specified predicate.

adjacentNodes

public Collection adjacentNodes(Object node,
                                org.apache.commons.collections.Predicate traverserPredicate)
Returns an empty collection.

Specified by:
adjacentNodes in interface Graph
Parameters:
node - return the nodes adjacent to this node for which the specified predicate is satisfied.
traverserPredicate - the predicate which the returned nodes and the traversed Graph.Edges must satisfy.
Returns:
the nodes adjacent to the specified node for which the specified predicate is satisfied.

incidentEdges

public Collection incidentEdges(Object node,
                                org.apache.commons.collections.Predicate traverserPredicate)
Returns an empty collection.

Specified by:
incidentEdges in interface Graph
Parameters:
node - return the Graph.Edges incident on this node for which the specified predicate is satisfied.
traverserPredicate - the predicate which the returned Graph.Edges must satisfy.
Returns:
the Graph.Edges incident on the specified node for which the specified predicate is satisfied.

getNode

public Object getNode(org.apache.commons.collections.Predicate nodePredicate)
Description copied from interface: Graph
Returns a node from this Graph that satisfies the specified predicate, or null if no such node exists.

Specified by:
getNode in interface Graph
Parameters:
nodePredicate - the predicate which the returned node must satisfy.
Returns:
a node from this Graph that satisfies the specified predicate, or null if no such node exists.

getEdge

public Graph.Edge getEdge(org.apache.commons.collections.Predicate edgePredicate)
Returns null.

Specified by:
getEdge in interface Graph
Parameters:
edgePredicate - the predicate which the returned Graph.Edge must satisfy.
Returns:
a Graph.Edge from this Graph that satisfies the specified predicate, or null if no such Graph.Edge exists.

getAdjacentNode

public Object getAdjacentNode(Object node,
                              org.apache.commons.collections.Predicate traverserPredicate)
Description copied from interface: Graph
Returns a node adjacent to the specified node for which the specified Predicate is satisfied. The argument to the Predicate.evaluate() method is expected to be an OrderedPair. The first element of the OrderedPair is the specified node, the second is the Graph.Edge.

Specified by:
getAdjacentNode in interface Graph
Parameters:
node - traverse to a node adjacent to this node for which the specified predicate is satisfied.
traverserPredicate - the predicate which the returned node and the traversed Graph.Edge must satisfy.
Returns:
a node adjacent to the specified node for which the specified predicate is satisfied.

getIncidentEdge

public Graph.Edge getIncidentEdge(Object node,
                                  org.apache.commons.collections.Predicate traverserPredicate)
Description copied from interface: Graph
Returns a Graph.Edge incident on the specified node for which the specified Predicate is satisfied. The argument to the Predicate.evaluate() method is expected to be an OrderedPair. The first element of the OrderedPair is the specified node, the second is the Graph.Edge.

Specified by:
getIncidentEdge in interface Graph
Parameters:
node - traverse to a Graph.Edge incident on this node for which the specified predicate is satisfied.
traverserPredicate - the predicate which the returned Graph.Edge must satisfy.
Returns:
a Graph.Edge incident on the specified node for which the specified predicate is satisfied.

traverser

public Traverser traverser(Object node,
                           org.apache.commons.collections.Predicate traverserPredicate)
Description copied from interface: Graph
Returns a Traverser from node to all adjacent nodes for which the specified Predicate is satisfied. The argument to the Predicate.evaluate() method is expected to be an OrderedPair. The first element of the OrderedPair is the specified node, the second is the Graph.Edge. The nodes returned by Iterator.next() are not necessarily distinct. Self-loops are only traversed once. There are no guarantees concerning the order in which the nodes are returned (unless this Graph is an instance of some class that provides a guarantee).

Specified by:
traverser in interface Graph
Parameters:
node - traverse over all nodes adjacent to this node for which the specified predicate is satisfied.
traverserPredicate - the predicate which the returned nodes and their traversed Graph.Edges must satisfy.
Returns:
a Traverser from node to all adjacent nodes for which the specified predicate is satisfied.

Plexus v0.13.1

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.