|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.uci.ics.jung.utils.GraphUtils
A series of helpful utility methods. All methods in GraphUtils can be accomplished with public members of other code; these are simply combinations that we found useful.
Constructor Summary | |
GraphUtils()
|
Method Summary | |
static void |
addDirectedVertices(Graph g,
int count)
Deprecated. As of version 1.2, replaced by addVertices(edu.uci.ics.jung.graph.Graph, int) . |
static Edge |
addEdge(Graph g,
Vertex v1,
Vertex v2)
Adds an appropriate edge between two vertices. |
static void |
addUndirectedVertices(Graph g,
int count)
Deprecated. As of version 1.2, replaced by addVertices(edu.uci.ics.jung.graph.Graph, int) . |
static void |
addVertices(Graph g,
int count)
Adds count vertices into a graph. |
static boolean |
areEquivalent(ArchetypeGraph g1,
ArchetypeGraph g2)
Returns true if g1 and g2 have equivalent
vertex and edge sets (that is, if each vertex and edge in g1
has an equivalent in g2 , and vice versa), and false
otherwise. |
static void |
copyLabels(StringLabeller source,
StringLabeller target)
Copies the labels of vertices from one StringLabeller to another. |
static Graph |
edgeSetToGraph(java.util.Set edges,
boolean retain)
Given a set of edges, creates a new Graph that contains all of those edges, and at least all the vertices that are attached to them. |
static java.util.Set |
getEqualEdges(java.util.Set s,
ArchetypeGraph g)
Returns the set of edges in g which are equal
to the edges in g . |
static java.util.Set |
getEqualVertices(java.util.Set s,
ArchetypeGraph g)
Returns the set of vertices in g which are equal
to the vertices in g . |
static java.lang.String |
printVertices(java.util.Collection s,
StringLabeller sl)
For every vertex in s, prints sl.get(s). |
static UndirectedGraph |
transform(DirectedGraph dGraph)
Deprecated. As of version 1.4, replaced by edu.ics.uci.jung.algorithms.transformation.DirectionTransformer#toUndirected(Graph) |
static DirectedGraph |
transform(Graph uGraph)
Deprecated. As of version 1.4, replaced by edu.ics.uci.jung.algorithms.transformation.DirectionTransformer#toDirected(Graph) |
static java.util.Set |
translateAll(java.util.Set s,
Graph g)
Deprecated. As of version 1.4, replaced by getEqualVertices(Set, ArchetypeGraph) |
static java.util.Set |
translateAllEdges(java.util.Set s,
Graph g)
Deprecated. As of version 1.4, replaced by getEqualVertices(Set, ArchetypeGraph) |
static Graph |
vertexSetToGraph(java.util.Set s)
Given a set of vertices, creates a new Graph that contains all of those vertices, and all the edges that connect them. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public GraphUtils()
Method Detail |
public static Edge addEdge(Graph g, Vertex v1, Vertex v2)
DirectedSparseEdge
,
otherwise a new
UndirectedSparseEdge
.
This is a convenience method; one might instead just call g.addEdge( new XXSparseEdge(v1, v2)))
.
The input vertices must be of type Vertex
,
or the method will throw a ClassCastException
.
java.lang.ClassCastException
- if the input aren't Vertices
java.lang.IllegalArgumentException
- if the vertices don't belong to the same graphGraph.addEdge(edu.uci.ics.jung.graph.Edge)
,
AbstractSparseGraph.addEdge(edu.uci.ics.jung.graph.Edge)
public static void addVertices(Graph g, int count)
count
vertices into a graph. This is a convenience
method; one might instead just call g.addVertex( new SparseVertex()))
count
times.
The input graph must be one that can accept a series of
directed vertices
.
g
- A graph to add the vertices tocount
- how many vertices to addAbstractSparseGraph.addVertex(edu.uci.ics.jung.graph.Vertex)
public static void addDirectedVertices(Graph g, int count)
addVertices(edu.uci.ics.jung.graph.Graph, int)
.
count
directed vertices into a graph. This is a
convenience method; one might instead just call g.addVertex( new DirectedSparseVertex()))
count
times.
The input graph must be one that can accept a series of
directed vertices
.
g
- A graph to add the vertices tocount
- how many vertices to addAbstractSparseGraph.addVertex(edu.uci.ics.jung.graph.Vertex)
public static void addUndirectedVertices(Graph g, int count)
addVertices(edu.uci.ics.jung.graph.Graph, int)
.
count
undirected vertices into a graph. This is a
convenience method; one might instead just call g.addVertex( new UndirectedSparseVertex()))
count
times.
The input graph must be one that can accept a series of
undirected vertices
.
g
- A graph to add the vertices tocount
- how many vertices to addAbstractSparseGraph.addVertex(edu.uci.ics.jung.graph.Vertex)
public static java.util.Set translateAll(java.util.Set s, Graph g)
getEqualVertices(Set, ArchetypeGraph)
set
into the graph
given. For each vertex, then, it gets the equivalent vertex in g
,
and returns the collated set.
s
- The set of input vertices, not from gg
- The graph which has the corresponding vertices
ArchetypeVertex.getEqualVertex(edu.uci.ics.jung.graph.ArchetypeGraph)
public static java.util.Set getEqualVertices(java.util.Set s, ArchetypeGraph g)
g
which are equal
to the vertices in g
.
public static java.util.Set translateAllEdges(java.util.Set s, Graph g)
getEqualVertices(Set, ArchetypeGraph)
set
into the graph
given. For each edge, then, it gets the equivalent edge in g
,
and returns the collated set.
s
- The set of input edges, not from gg
- The graph which has the corresponding edges
ArchetypeEdge.getEqualEdge(edu.uci.ics.jung.graph.ArchetypeGraph)
public static java.util.Set getEqualEdges(java.util.Set s, ArchetypeGraph g)
g
which are equal
to the edges in g
.
public static Graph vertexSetToGraph(java.util.Set s)
UnassembledGraph
mechanism to create the graph.
s
- A set of Vertex s that want to be a part of a new
Graph
Graph.newInstance
,
containing vertices equivalent to (and that are copies of!) all
the vertices in the input set. Note that if the input is an
empty set, null is returned.public static Graph edgeSetToGraph(java.util.Set edges, boolean retain)
UnassembledGraph
mechanism to create the graph. The parameter decides what to do with
disconnected vertices: true says that they should be
retained, false says that they should be discarded (with a
DropSoloNodesFilter
).
edges
- A set of Edge s that want to be a part of a new
Graphretain
- Is true if all isolated vertices should be retained; is false if they
should be discarded.
Graph.newInstance
,
containing edges equivalent to (and that are copies of!) all the
edges in the input set. Note that if the input is an empty set,
null is returned.public static DirectedGraph transform(Graph uGraph)
edu.ics.uci.jung.algorithms.transformation.DirectionTransformer#toDirected(Graph)
uGraph
- the undirected graph to transform
public static UndirectedGraph transform(DirectedGraph dGraph)
edu.ics.uci.jung.algorithms.transformation.DirectionTransformer#toUndirected(Graph)
dGraph
- the directed graph to transform
public static void copyLabels(StringLabeller source, StringLabeller target) throws StringLabeller.UniqueLabelException
source
- the source StringLabellertarget
- the target StringLabeller
StringLabeller.UniqueLabelException
public static boolean areEquivalent(ArchetypeGraph g1, ArchetypeGraph g2)
g1
and g2
have equivalent
vertex and edge sets (that is, if each vertex and edge in g1
has an equivalent in g2
, and vice versa), and false
otherwise.
public static java.lang.String printVertices(java.util.Collection s, StringLabeller sl)
s
- sl
-
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |