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

Quick Search    Search Deep

com.phoenixst.plexus
Interface Graph  view Graph download Graph.java

All Known Subinterfaces:
ObservableGraph
All Known Implementing Classes:
AbstractGraph, DefaultGraph, GraphUtils.SynchronizedObservableGraphWrapper, GraphUtils.UnmodifiableObservableGraphWrapper, GraphWrapper, ObservableGraphWrapper

public interface Graph

The root interface of the graph hierarchy.

See the Overview Summary for details not included here.

Nodes must contain unique (using Object.equals() 55 ) user-provided objects. This requirement allows nodes to be referenced unambiguously (when creating edges, for example). The user-defined objects contained in Graph.Edge objects, however, are not subject to this requirement in the general case, although Object.equals() will be used for edge comparisons.

Nothing in this interface prohibits a Graph.Edge from also being a node in the same Graph. In other words, Edges can point to other Edges. If a particular Graph implementation allows this, these two aspects of any particular Edge are independent. Adding or removing an Edge as a node has no impact upon the object's existence as an Edge, and vice versa.

All general-purpose implementations of this interface should provide two "standard" constructors: a void (no arguments) constructor, which creates an empty graph, and a constructor with a single argument of type Graph, which creates a new graph with the same elements as its argument.

Since:
1.0
Version:
$Revision: 1.17 $

Nested Class Summary
static interface Graph.Edge
          An interface describing an edge in a Graph.
 
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.
 

Method Detail

isDirected

public boolean isDirected()
Returns whether or not this Graph is directed.


isSimple

public boolean isSimple()
Returns whether or not this Graph is simple.


isEmpty

public boolean isEmpty()
Returns true if this Graph contains no edges, it may contain nodes.


nodeSize

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


edgeSize

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


degree

public 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. If this node has more than Integer.MAX_VALUE incident edges, returns Integer.MAX_VALUE.


outDegree

public 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. 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.


inDegree

public 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. 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.


addNode

public boolean addNode(java.lang.Object node)
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.


removeNode

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


containsNode

public boolean containsNode(java.lang.Object node)
Returns true if this Graph contains the specified node.


addEdge

public Graph.Edge addEdge(java.lang.Object object,
                          java.lang.Object tail,
                          java.lang.Object head)
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.


removeEdge

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


containsEdge

public boolean containsEdge(Graph.Edge edge)
Returns true if this Graph contains the specified Edge.


getEdge

public 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.


clear

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


nodeIterator

public java.util.Iterator nodeIterator()
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).


edgeIterator

public java.util.Iterator edgeIterator()
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).


edgeIterator

public 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.


traverser

public Traverser traverser(java.lang.Object node)
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).


outTraverser

public 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. 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).


inTraverser

public 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. 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).