Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.phoenixst.plexus
Class GraphWrapper  view GraphWrapper download GraphWrapper.java

java.lang.Object
  extended bycom.phoenixst.plexus.GraphWrapper
All Implemented Interfaces:
Graph, java.io.Serializable
Direct Known Subclasses:
GraphTransformer, GraphUtils.SynchronizedGraphWrapper, GraphUtils.UnmodifiableGraphWrapper, ObservableGraphWrapper

public class GraphWrapper
extends java.lang.Object
implements Graph, java.io.Serializable

A Graph which wraps another. This class is intended to be extended.

Since:
1.0
Version:
$Revision: 1.12 $

Nested Class Summary
protected  class GraphWrapper.EdgeIteratorWrapper
          Protected edge iterator implementation.
protected  class GraphWrapper.EdgeWrapper
          Edge wrapper.
protected  class GraphWrapper.NodeIteratorWrapper
          Protected node iterator implementation.
protected  class GraphWrapper.TraverserWrapper
          Protected implementation of Traverser.
 
Nested classes inherited from class com.phoenixst.plexus.Graph
Graph.Edge
 
Field Summary
protected  Graph g
          The wrapped graph.
 
Constructor Summary
GraphWrapper(Graph g)
          Creates a new GraphWrapper.
 
Method Summary
 Graph.Edge addEdge(java.lang.Object object, java.lang.Object tail, java.lang.Object head)
          Adds the specified edge to the Graph (optional operation).
 boolean addNode(java.lang.Object node)
          Adds node to this Graph (optional operation).
 void clear()
          Removes all nodes and edges from this Graph (optional operation).
 boolean containsEdge(Graph.Edge edge)
          Returns true if this Graph contains the specified Edge.
 boolean containsNode(java.lang.Object node)
          Returns true if this Graph contains the specified node.
 int degree(java.lang.Object node)
          Returns the degree of node, defined as the number of edges incident on node, with self-loops counted twice.
 java.util.Iterator edgeIterator()
          Returns an Iterator over all the Edges in this Graph.
 java.util.Iterator edgeIterator(java.lang.Object tail, java.lang.Object head)
          Returns an Iterator over all Edges from this Graph with the specified tail and head.
 int edgeSize()
          Returns the number of edges in this Graph.
 Graph.Edge getEdge(java.lang.Object tail, java.lang.Object head)
          Returns an Edge from this Graph with the specified tail and head, or null if it does not exist.
 int inDegree(java.lang.Object node)
          If this is a directed graph, returns the in degree of node, defined as the number of edges entering node.
 Traverser inTraverser(java.lang.Object node)
          If this is a directed graph, returns a Traverser from node to all adjacent nodes reachable through edges whose head is the given node.
 boolean isDirected()
          Returns whether or not this Graph is directed.
 boolean isEmpty()
          Returns true if this Graph contains no edges, it may contain nodes.
 boolean isSimple()
          Returns whether or not this Graph is simple.
 java.util.Iterator nodeIterator()
          Returns an Iterator over all the nodes in this Graph.
 int nodeSize()
          Returns the number of nodes in this Graph.
 int outDegree(java.lang.Object node)
          If this is a directed graph, returns the out degree of node, defined as the number of edges leaving node.
 Traverser outTraverser(java.lang.Object node)
          If this is a directed graph, returns a Traverser from node to all adjacent nodes reachable through edges whose tail is the given node.
 boolean removeEdge(Graph.Edge edge)
          Removes the specified Edge from this Graph (optional operation).
 boolean removeNode(java.lang.Object node)
          Removes node from this Graph (optional operation).
 Traverser traverser(java.lang.Object node)
          Returns a Traverser from node to all adjacent nodes.
protected  Graph.Edge unwrapEdge(Graph.Edge edge)
          Returns an unwrapped Edge, or null if the edge didn't come from this graph.
protected  java.lang.Object unwrapEdgeObject(java.lang.Object edgeObject)
          Returns an unwrapped edge Object.
protected  java.lang.Object unwrapNode(java.lang.Object node)
          Returns an unwrapped node.
protected  GraphWrapper.EdgeWrapper wrapEdge(Graph.Edge edge)
          Returns a wrapped Edge.
protected  java.util.Iterator wrapEdgeIterator(java.util.Iterator edgeIter)
          Returns a wrapped edge iterator.
protected  java.lang.Object wrapEdgeObject(java.lang.Object edgeObject)
          Returns a wrapped edge Object.
protected  java.lang.Object wrapNode(java.lang.Object node)
          Returns a wrapped node.
protected  java.util.Iterator wrapNodeIterator(java.util.Iterator nodeIter)
          Returns a wrapped node iterator.
protected  Traverser wrapTraverser(Traverser traverser)
          Returns a wrapped traverser.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

g

protected Graph g
The wrapped graph.

Constructor Detail

GraphWrapper

public GraphWrapper(Graph g)
Creates a new GraphWrapper.

Method Detail

wrapNode

protected java.lang.Object wrapNode(java.lang.Object node)
Returns a wrapped node. If the argument node is an Edge produced by the wrapped graph, then it wraps it as an Edge.


unwrapNode

protected java.lang.Object unwrapNode(java.lang.Object node)
Returns an unwrapped node. If the argument node is an Edge produced by this graph, then it returns the unwrapped Edge.


wrapEdgeObject

protected java.lang.Object wrapEdgeObject(java.lang.Object edgeObject)
Returns a wrapped edge Object.


unwrapEdgeObject

protected java.lang.Object unwrapEdgeObject(java.lang.Object edgeObject)
Returns an unwrapped edge Object.


wrapEdge

protected GraphWrapper.EdgeWrapper wrapEdge(Graph.Edge edge)
Returns a wrapped Edge.


unwrapEdge

protected Graph.Edge unwrapEdge(Graph.Edge edge)
Returns an unwrapped Edge, or null if the edge didn't come from this graph.


wrapNodeIterator

protected java.util.Iterator wrapNodeIterator(java.util.Iterator nodeIter)
Returns a wrapped node iterator.


wrapEdgeIterator

protected java.util.Iterator wrapEdgeIterator(java.util.Iterator edgeIter)
Returns a wrapped edge iterator.


wrapTraverser

protected Traverser wrapTraverser(Traverser traverser)
Returns a wrapped traverser.


isDirected

public boolean isDirected()
Description copied from interface: Graph
Returns whether or not this Graph is directed.

Specified by:
isDirected in interface Graph

isSimple

public boolean isSimple()
Description copied from interface: Graph
Returns whether or not this Graph is simple.

Specified by:
isSimple in interface Graph

isEmpty

public boolean isEmpty()
Description copied from interface: Graph
Returns true if this Graph contains no edges, it may contain nodes.

Specified by:
isEmpty in interface Graph

nodeSize

public int nodeSize()
Description copied from interface: Graph
Returns the number of nodes in this Graph. If this Graph contains more than Integer.MAX_VALUE nodes, returns Integer.MAX_VALUE.

Specified by:
nodeSize in interface Graph

edgeSize

public int edgeSize()
Description copied from interface: Graph
Returns the number of edges in this Graph. If this Graph contains more than Integer.MAX_VALUE edges, returns Integer.MAX_VALUE.

Specified by:
edgeSize in interface Graph

degree

public int degree(java.lang.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

outDegree

public int outDegree(java.lang.Object node)
Description copied from interface: Graph
If this is a directed graph, returns the out degree of node, defined as the number of edges leaving node. If this is not a directed graph, throws UnsupportedOperationException. If this node has more than Integer.MAX_VALUE edges leaving it, returns Integer.MAX_VALUE.

Specified by:
outDegree in interface Graph

inDegree

public int inDegree(java.lang.Object node)
Description copied from interface: Graph
If this is a directed graph, returns the in degree of node, defined as the number of edges entering node. If this is not a directed graph, throws UnsupportedOperationException. If this node has more than Integer.MAX_VALUE edges entering it, returns Integer.MAX_VALUE.

Specified by:
inDegree in interface Graph

addNode

public boolean addNode(java.lang.Object node)
Description copied from interface: Graph
Adds node to this Graph (optional operation). Returns true if this Graph changed as a result of the call. Returns false if this Graph already contains node.

If a Graph refuses to add a particular node for any reason other than that it already contains the node, it must throw an exception (rather than returning false). This preserves the invariant that a Graph always contains the specified node after this call returns. Graph classes should clearly specify in their documentation any other restrictions on what nodes may be added.

Specified by:
addNode in interface Graph

removeNode

public boolean removeNode(java.lang.Object node)
Description copied from interface: Graph
Removes node from this Graph (optional operation). This method will also remove all edges incident upon node.

Specified by:
removeNode in interface Graph

containsNode

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

Specified by:
containsNode in interface Graph

addEdge

public Graph.Edge addEdge(java.lang.Object object,
                          java.lang.Object tail,
                          java.lang.Object head)
Description copied from interface: Graph
Adds the specified edge to the Graph (optional operation). Returns the newly created Edge if this Graph changed as a result of the call. Returns null if this Graph does not allow duplicate edges and already contains the specified edge.

If a Graph refuses to add a particular edge for any reason other than that it already contains the edge, it must throw an exception (rather than returning null). This preserves the invariant that a Graph always contains the specified edge after this call returns. Graph classes should clearly specify in their documentation any other restrictions on what edges may be added.

Specified by:
addEdge in interface Graph

removeEdge

public boolean removeEdge(Graph.Edge edge)
Description copied from interface: Graph
Removes the specified Edge from this Graph (optional operation).

Specified by:
removeEdge in interface Graph

containsEdge

public boolean containsEdge(Graph.Edge edge)
Description copied from interface: Graph
Returns true if this Graph contains the specified Edge.

Specified by:
containsEdge in interface Graph

getEdge

public Graph.Edge getEdge(java.lang.Object tail,
                          java.lang.Object head)
Description copied from interface: Graph
Returns an Edge from this Graph with the specified tail and head, or null if it does not exist.

Specified by:
getEdge in interface Graph

clear

public void clear()
Description copied from interface: Graph
Removes all nodes and edges from this Graph (optional operation).

Specified by:
clear in interface Graph

nodeIterator

public java.util.Iterator nodeIterator()
Description copied from interface: Graph
Returns an Iterator over all the nodes in this Graph. Calling Iterator.remove()>Iterator.remove() 55 removes the last node returned by the Iterator, and all edges incident upon that node, from this Graph. 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:
nodeIterator in interface Graph

edgeIterator

public java.util.Iterator edgeIterator()
Description copied from interface: Graph
Returns an Iterator over all the Edges in this Graph. There are no guarantees concerning the order in which the edges are returned (unless this Graph is an instance of some class that provides a guarantee).

Specified by:
edgeIterator in interface Graph

edgeIterator

public java.util.Iterator edgeIterator(java.lang.Object tail,
                                       java.lang.Object head)
Description copied from interface: Graph
Returns an Iterator over all Edges from this Graph with the specified tail and head.

Specified by:
edgeIterator in interface Graph

traverser

public Traverser traverser(java.lang.Object node)
Description copied from interface: Graph
Returns a Traverser from node to all adjacent nodes. If the implementation is a multigraph, the nodes returned by Iterator.next()>Iterator.next() 55 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

outTraverser

public Traverser outTraverser(java.lang.Object node)
Description copied from interface: Graph
If this is a directed graph, returns a Traverser from node to all adjacent nodes reachable through edges whose tail is the given node. If this is not a directed graph, throws UnsupportedOperationException. If the implementation is a multigraph, the nodes returned by Iterator.next()>Iterator.next() 55 are not necessarily distinct. 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:
outTraverser in interface Graph

inTraverser

public Traverser inTraverser(java.lang.Object node)
Description copied from interface: Graph
If this is a directed graph, returns a Traverser from node to all adjacent nodes reachable through edges whose head is the given node. If this is not a directed graph, throws UnsupportedOperationException. If the implementation is a multigraph, the nodes returned by Iterator.next()>Iterator.next() 55 are not necessarily distinct. 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:
inTraverser in interface Graph