public class LoggingGraph extends Object implements ObservableGraph
Graph which wraps another to provide logging
support.Graph.Edge| Constructor and Description |
|---|
LoggingGraph(Graph delegate)
Creates a new
LoggingGraph which
logs to a category corresponding to this class at
the DEBUG level. |
LoggingGraph(Graph delegate,
org.apache.log4j.Logger logger)
Creates a new
LoggingGraph which uses
the specified log at the DEBUG level. |
LoggingGraph(Graph delegate,
org.apache.log4j.Logger logger,
org.apache.log4j.Level level)
Creates a new
LoggingGraph. |
| Modifier and Type | Method and Description |
|---|---|
Graph.Edge |
addEdge(Object object,
Object tail,
Object head,
boolean isDirected)
Adds the specified edge to the
Graph (optional
operation). |
void |
addGraphListener(GraphListener listener)
Adds the specified
GraphListener which will be
notified whenever this ObservableGraph's
structure changes. |
boolean |
addNode(Object node)
Adds
node to this Graph (optional
operation). |
Collection |
adjacentNodes(Object node,
org.apache.commons.collections.Predicate traverserPredicate)
Returns the nodes adjacent to the specified
node
for which the specified Predicate is satisfied. |
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. |
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 the
Graph.Edges from this
Graph that satisfy the specified
predicate. |
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. |
protected Graph |
getDelegate()
Provides access to internal state so it can be used
by extensions of this class.
|
Graph.Edge |
getEdge(org.apache.commons.collections.Predicate edgePredicate)
Returns a
Graph.Edge from this Graph
that satisfies the specified predicate, or
null if no such Graph.Edge exists. |
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. |
protected org.apache.log4j.Level |
getLevel()
Provides access to internal state so it can be used
by extensions of this class.
|
protected org.apache.log4j.Logger |
getLogger()
Provides access to internal state so it can be used
by extensions of this class.
|
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 the
Graph.Edges incident on the specified
node for which the specified
Predicate is satisfied. |
Collection |
nodes(org.apache.commons.collections.Predicate nodePredicate)
Returns the nodes from this
Graph that satisfy
the specified predicate. |
boolean |
removeEdge(Graph.Edge edge)
Removes the specified
Graph.Edge from this
Graph (optional operation). |
void |
removeGraphListener(GraphListener listener)
Removes a previously added
GraphListener. |
boolean |
removeNode(Object node)
Removes
node from this Graph
(optional operation). |
String |
toString() |
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. |
public LoggingGraph(Graph delegate)
LoggingGraph which
logs to a category corresponding to this class at
the DEBUG level.public LoggingGraph(Graph delegate, org.apache.log4j.Logger logger)
LoggingGraph which uses
the specified log at the DEBUG level.public LoggingGraph(Graph delegate, org.apache.log4j.Logger logger, org.apache.log4j.Level level)
LoggingGraph.protected final Graph getDelegate()
protected final org.apache.log4j.Logger getLogger()
protected final org.apache.log4j.Level getLevel()
public boolean addNode(Object node)
Graphnode 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.
public boolean removeNode(Object node)
Graphnode from this Graph
(optional operation). This method will also remove all edges
incident on node.removeNode in interface Graphnode - the node to be removed from this
Graph.true if this Graph contained
node.public boolean containsNode(Object node)
Graphtrue if this Graph contains
the specified node.containsNode in interface Graphnode - the node whose presence in this Graph
is to be tested.true if this Graph contains
the specified node.public Graph.Edge addEdge(Object object, Object tail, Object head, boolean isDirected)
GraphGraph (optional
operation). Returns the newly created Graph.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.
addEdge in interface Graphobject - 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.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.public boolean removeEdge(Graph.Edge edge)
GraphGraph.Edge from this
Graph (optional operation).removeEdge in interface Graphedge - the Graph.Edge to be removed from
this Graph.true if this Graph contained
the specified Graph.Edge.public boolean containsEdge(Graph.Edge edge)
Graphtrue if this Graph contains
the specified Graph.Edge.containsEdge in interface Graphedge - the Graph.Edge whose presence in this
Graph is to be tested.true if this Graph contains
the specified Graph.Edge.public int degree(Object node)
Graphnode, 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.public int degree(Object node, org.apache.commons.collections.Predicate traverserPredicate)
Graphnode 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.public Collection nodes(org.apache.commons.collections.Predicate nodePredicate)
GraphGraph that satisfy
the specified predicate.public Collection edges(org.apache.commons.collections.Predicate edgePredicate)
GraphGraph.Edges from this
Graph that satisfy the specified
predicate.public Collection adjacentNodes(Object node, org.apache.commons.collections.Predicate traverserPredicate)
Graphnode
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.
It should be noted that removing a node from the returned
Collection merely removes one instance of it
being adjacent to the specified node. In other
words, a connecting Graph.Edge is removed.adjacentNodes in interface Graphnode - 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.node
for which the specified predicate is satisfied.public Collection incidentEdges(Object node, org.apache.commons.collections.Predicate traverserPredicate)
GraphGraph.Edges 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.incidentEdges in interface Graphnode - 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.Graph.Edges incident on the specified
node for which the specified predicate is
satisfied.public Object getNode(org.apache.commons.collections.Predicate nodePredicate)
GraphGraph that satisfies the
specified predicate, or null if no
such node exists.public Graph.Edge getEdge(org.apache.commons.collections.Predicate edgePredicate)
GraphGraph.Edge from this Graph
that satisfies the specified predicate, or
null if no such Graph.Edge exists.public Object getAdjacentNode(Object node, org.apache.commons.collections.Predicate traverserPredicate)
Graphnode 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.getAdjacentNode in interface Graphnode - 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.node for
which the specified predicate is satisfied.public Graph.Edge getIncidentEdge(Object node, org.apache.commons.collections.Predicate traverserPredicate)
GraphGraph.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.getIncidentEdge in interface Graphnode - 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.Graph.Edge incident on the specified
node for which the specified predicate is
satisfied.public Traverser traverser(Object node, org.apache.commons.collections.Predicate traverserPredicate)
GraphTraverser 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).traverser in interface Graphnode - 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.Traverser from node to all
adjacent nodes for which the specified predicate is satisfied.public void addGraphListener(GraphListener listener)
GraphListener which will be
notified whenever this ObservableGraph's
structure changes. If the wrapped graph does not implement
ObservableGraph, then this method with throw an
UnsupportedOperationException.addGraphListener in interface ObservableGraphpublic void removeGraphListener(GraphListener listener)
GraphListener. If the
wrapped graph does not implement ObservableGraph, then
this method with throw an
UnsupportedOperationException.removeGraphListener in interface ObservableGraphSee 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.