public class GraphUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
ANY_DIRECTION_MASK |
static org.apache.commons.collections.Predicate |
DIRECTED_EDGE_PREDICATE
An
Graph.Edge predicate which is
true when directed. |
static int |
DIRECTED_IN_MASK |
static int |
DIRECTED_MASK |
static int |
DIRECTED_OUT_MASK |
static org.apache.commons.collections.Predicate |
DIRECTED_TRAVERSER_PREDICATE
A
Traverser predicate which is true when
the edge is directed. |
static Traverser |
EMPTY_TRAVERSER
An empty
Traverser. |
static org.apache.commons.collections.Predicate |
IN_TRAVERSER_PREDICATE
A
Traverser predicate which is true
when the edge is directed in. |
static ObservableGraph |
NULL_GRAPH
An immutable,
ObservableGraph with no nodes or edges. |
static org.apache.commons.collections.Predicate |
OUT_TRAVERSER_PREDICATE
A
Traverser predicate which is true
when the edge is directed out. |
static org.apache.commons.collections.Predicate |
SELF_EDGE_PREDICATE
An
Graph.Edge predicate which is
true when the edge is a self-loop. |
static org.apache.commons.collections.Predicate |
SELF_TRAVERSER_PREDICATE
A
Traverser predicate which is true
when the edge is a self-loop. |
static org.apache.commons.collections.Predicate |
UNDIRECTED_EDGE_PREDICATE
An
Graph.Edge predicate which is
true when undirected. |
static int |
UNDIRECTED_MASK |
static org.apache.commons.collections.Predicate |
UNDIRECTED_TRAVERSER_PREDICATE
A
Traverser predicate which is true
when the edge is undirected. |
| Modifier and Type | Method and Description |
|---|---|
static void |
add(Graph destination,
Graph source)
Adds all the nodes and edges from
source to
destination. |
static String |
directionFlagsToString(int directionFlags)
Returns a String representation of the specified direction flags.
|
static boolean |
equals(Object a,
Object b)
Tests two objects for being
.equals(), handling
null appropriately. |
static Object |
getFirstCommonNode(org.apache.commons.collections.Transformer incidentEdgeGetter,
Object a,
Object b)
Helper method primarily for
OrientedForest
implementations. |
static Object |
getLeastCommonAncestor(OrientedForest forest,
Object a,
Object b)
Helper method for
OrientedForest implementations. |
static CharSequence |
getTextValue(Graph.Edge edge,
boolean includeUserObject)
Returns a CharSequence representing the specified edge.
|
static int |
invertDirection(int directionFlags)
Returns the inverse of the specified direction flags.
|
static Iterator |
singletonEdgeIterator(Graph graph,
Graph.Edge edge)
Returns a modifiable
Iterator over the specified
edge. |
static Graph |
singletonGraph(Object node)
Returns an unmodifiable, serializable
Graph with
the single specified node and no edges. |
static Traverser |
singletonTraverser(Graph graph,
Object endpoint,
Graph.Edge edge)
Returns a modifiable
Traverser over the specified
edge. |
static ObservableGraph |
synchronizedGraph(Graph graph)
Returns a synchronized view of the specified
Graph. |
static ObservableGraph |
unmodifiableGraph(Graph graph)
Returns an unmodifiable view of the specified
Graph. |
static Iterator |
unmodifiableIterator(Iterator iterator)
Returns an unmodifiable view of the specified
Iterator. |
static Traverser |
unmodifiableTraverser(Traverser traverser)
Returns an unmodifiable view of the specified
Traverser. |
public static final int UNDIRECTED_MASK
public static final int DIRECTED_OUT_MASK
public static final int DIRECTED_IN_MASK
public static final int DIRECTED_MASK
public static final int ANY_DIRECTION_MASK
public static final Traverser EMPTY_TRAVERSER
Traverser.public static final ObservableGraph NULL_GRAPH
ObservableGraph with no nodes or edges.public static final org.apache.commons.collections.Predicate DIRECTED_EDGE_PREDICATE
Graph.Edge predicate which is
true when directed.public static final org.apache.commons.collections.Predicate UNDIRECTED_EDGE_PREDICATE
Graph.Edge predicate which is
true when undirected.public static final org.apache.commons.collections.Predicate SELF_EDGE_PREDICATE
Graph.Edge predicate which is
true when the edge is a self-loop.public static final org.apache.commons.collections.Predicate OUT_TRAVERSER_PREDICATE
Traverser predicate which is true
when the edge is directed out.public static final org.apache.commons.collections.Predicate IN_TRAVERSER_PREDICATE
Traverser predicate which is true
when the edge is directed in.public static final org.apache.commons.collections.Predicate DIRECTED_TRAVERSER_PREDICATE
Traverser predicate which is true when
the edge is directed.public static final org.apache.commons.collections.Predicate UNDIRECTED_TRAVERSER_PREDICATE
Traverser predicate which is true
when the edge is undirected.public static final org.apache.commons.collections.Predicate SELF_TRAVERSER_PREDICATE
Traverser predicate which is true
when the edge is a self-loop.public static final int invertDirection(int directionFlags)
public static final String directionFlagsToString(int directionFlags)
"none"
"any"
"-"
">"
"<"
"< >"
"- >"
"< -"
public static CharSequence getTextValue(Graph.Edge edge, boolean includeUserObject)
public static void add(Graph destination, Graph source)
source to
destination. If the two Graphs are
incompatible in some way (nodes and/or edges from from the
source graph not allowed in the destination), then a best
effort is still made.public static final boolean equals(Object a, Object b)
.equals(), handling
null appropriately.public static Object getLeastCommonAncestor(OrientedForest forest, Object a, Object b)
OrientedForest implementations.public static Object getFirstCommonNode(org.apache.commons.collections.Transformer incidentEdgeGetter, Object a, Object b)
OrientedForest
implementations. This method will repeatedly apply the
Transformer to each node argument until
it returns null, so the traversal should
terminate.public static Graph singletonGraph(Object node)
Graph with
the single specified node and no edges.node - the node which the returned Graph is
to contain.Graph with
the single specified node and no edges.public static Iterator singletonEdgeIterator(Graph graph, Graph.Edge edge)
Iterator over the specified
edge.graph - the graph containing the edge over which the
returned Iterator iterates.edge - the edge over which the returned
Iterator iterates.Iterator over the specified
edge.public static Traverser singletonTraverser(Graph graph, Object endpoint, Graph.Edge edge)
Traverser over the specified
edge.graph - the graph containing the edge over which the
returned Traverser iterates.endpoint - the endpoint of the edge over which the
returned Traverser iterates.edge - the edge over which the returned
Traverser iterates.Traverser over the specified
edge.public static Iterator unmodifiableIterator(Iterator iterator)
Iterator.iterator - the Iterator for which an
unmodifiable view is to be returned.Iterator.public static Traverser unmodifiableTraverser(Traverser traverser)
Traverser.traverser - the Traverser for which an
unmodifiable view is to be returned.Traverser.public static ObservableGraph unmodifiableGraph(Graph graph)
Graph. If the specified Graph does
not implement ObservableGraph, then ObservableGraph.addGraphListener(com.phoenixst.plexus.GraphListener) and ObservableGraph.removeGraphListener(com.phoenixst.plexus.GraphListener) with throw
UnsupportedOperationExceptions. The returned
Graph will be serializable if the specified
Graph is serializable.graph - the Graph for which an unmodifiable
view is to be returned.Graph.public static ObservableGraph synchronizedGraph(Graph graph)
Graph. It is the user's responsibility to
manually synchronize on the returned Graph when
iterating over it. If the specified Graph does
not implement ObservableGraph, then ObservableGraph.addGraphListener(com.phoenixst.plexus.GraphListener) and ObservableGraph.removeGraphListener(com.phoenixst.plexus.GraphListener) with throw
UnsupportedOperationExceptions. The returned
Graph will be serializable if the specified
Graph is serializable.graph - the Graph for which a synchronized
view is to be returned.Graph.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.