|
|||||||||
| Home >> All >> com >> phoenixst >> [ plexus overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.phoenixst.plexus
Interface Graph

- 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
Graphis directed.
isSimple
public boolean isSimple()
- Returns whether or not this
Graphis simple.
isEmpty
public boolean isEmpty()
- Returns
trueif thisGraphcontains no edges, it may contain nodes.
nodeSize
public int nodeSize()
- Returns the number of nodes in this
Graph. If thisGraphcontains more thanInteger.MAX_VALUEnodes, returnsInteger.MAX_VALUE.
edgeSize
public int edgeSize()
- Returns the number of edges in this
Graph. If thisGraphcontains more thanInteger.MAX_VALUEedges, returnsInteger.MAX_VALUE.
degree
public int degree(java.lang.Object node)
- Returns the degree of
node, defined as the number of edges incident onnode, with self-loops counted twice. If this node has more thanInteger.MAX_VALUEincident edges, returnsInteger.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 leavingnode. If this is not a directed graph, throwsUnsupportedOperationException. If this node has more thanInteger.MAX_VALUEedges leaving it, returnsInteger.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 enteringnode. If this is not a directed graph, throwsUnsupportedOperationException. If this node has more thanInteger.MAX_VALUEedges entering it, returnsInteger.MAX_VALUE.
addNode
public boolean addNode(java.lang.Object node)
- Adds
nodeto thisGraph(optional operation). Returnstrueif thisGraphchanged as a result of the call. Returnsfalseif thisGraphalready containsnode.If a
Graphrefuses to add a particular node for any reason other than that it already contains the node, it must throw an exception (rather than returningfalse). This preserves the invariant that aGraphalways contains the specified node after this call returns.Graphclasses should clearly specify in their documentation any other restrictions on what nodes may be added.
removeNode
public boolean removeNode(java.lang.Object node)
- Removes
nodefrom thisGraph(optional operation). This method will also remove all edges incident uponnode.
containsNode
public boolean containsNode(java.lang.Object node)
- Returns
trueif thisGraphcontains 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 createdEdgeif thisGraphchanged as a result of the call. Returnsnullif thisGraphdoes not allow duplicate edges and already contains the specified edge.If a
Graphrefuses to add a particular edge for any reason other than that it already contains the edge, it must throw an exception (rather than returningnull). This preserves the invariant that aGraphalways contains the specified edge after this call returns.Graphclasses 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
Edgefrom thisGraph(optional operation).
containsEdge
public boolean containsEdge(Graph.Edge edge)
- Returns
trueif thisGraphcontains the specifiedEdge.
getEdge
public Graph.Edge getEdge(java.lang.Object tail, java.lang.Object head)
- Returns an
Edgefrom thisGraphwith the specified tail and head, ornullif 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
Iteratorover all the nodes in thisGraph. Calling Iterator.remove()>Iterator.remove()55 removes the last node returned by theIterator, and all edges incident upon that node, from thisGraph. There are no guarantees concerning the order in which the nodes are returned (unless thisGraphis an instance of some class that provides a guarantee).
edgeIterator
public java.util.Iterator edgeIterator()
- Returns an
Iteratorover all theEdgesin thisGraph. There are no guarantees concerning the order in which the edges are returned (unless thisGraphis 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
Iteratorover allEdgesfrom thisGraphwith the specified tail and head.
traverser
public Traverser traverser(java.lang.Object node)
- Returns a
Traverserfromnodeto 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 thisGraphis 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
Traverserfromnodeto all adjacent nodes reachable through edges whose tail is the given node. If this is not a directed graph, throwsUnsupportedOperationException. 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 thisGraphis 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
Traverserfromnodeto all adjacent nodes reachable through edges whose head is the given node. If this is not a directed graph, throwsUnsupportedOperationException. 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 thisGraphis an instance of some class that provides a guarantee).
|
|||||||||
| Home >> All >> com >> phoenixst >> [ plexus overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC