|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.uci.ics.jung.algorithms.blockmodel.GraphCollapser
public class GraphCollapser
This is a skeleton class for collapsing graphs. In particular, it takes in a Graph g and a set of vertices to be collapsed into one, "rootset". It then returns a variant of the graph in which the root set has been merged into one vertex (of class CollapsedVertex). The user has the opportunity to override a number of these functions (thus, the need for instantiation only exists for overriding). There are several issues to be resolved:
getCollapsedVertex(Set vertices)
annotateVertex(Vertex collapsedVertex, Set original vertices)
protected boolean shouldAddEdge(
Vertex opposite,
Set rootSet,
Collection edges)
public void addDirectedEdges(
Graph graph,
Vertex superVertex,
Vertex opposite,
Set relevantEdges)
protected void addUndirectedEdge(Vertex opposite, Vertex superVertex, Set relevantEdges) {
protected boolean shouldAddEdge(
Vertex opposite,
Set rootSet,
Collection edges) {
Nested Class Summary | |
---|---|
static interface |
GraphCollapser.CollapsedEdge
The CollapsedEdge interface represents a set of edges in some other graph. |
static class |
GraphCollapser.CollapsedSparseVertex
A CollapsedSparseVertex extends CollapsedVertex. |
static interface |
GraphCollapser.CollapsedVertex
This interface represents a vertex that holds a set of objects in some other graph. |
static class |
GraphCollapser.DirectedCollapsedEdge
This class represents a Collapsed Directed edge, and extends DirectedSparseEdge. |
static class |
GraphCollapser.UndirectedCollapsedEdge
This class represents a Collapsed Undirected edge, and extends UndirectedSparseEdge. |
Field Summary | |
---|---|
protected static GraphCollapser |
instance
|
Constructor Summary | |
---|---|
protected |
GraphCollapser()
|
Method Summary | |
---|---|
protected void |
annotateEdge(GraphCollapser.CollapsedEdge newEdge,
Collection edgesFromWhichWeMightDeriveData)
Overridable method annotates the new collapsed edge with userdata from the original set. |
protected void |
annotateVertex(GraphCollapser.CollapsedVertex superVertex,
Set rootSet)
Overridable method annotates the new collapsed vertex with userdata from the rootset. |
protected void |
collapseVerticesIntoSuperVertices(EquivalenceRelation er,
Map superVertices,
MultiMap vertices_to_edges)
Internal method for collapsing a set of vertexes. |
protected GraphCollapser.CollapsedVertex |
createCollapsedVertex(Graph g,
Set rootSet)
Overridable method to create a single vertex representing a set of vertices in the graph. |
protected void |
createDirectedEdges(Graph graph,
GraphCollapser.CollapsedVertex superVertex,
Vertex opposite,
Set relevantEdges)
Overridable method to create a up to two directed edges that represents the data in its parameters. |
protected void |
createEdgesCorrespondingToMap(Graph copy,
GraphCollapser.CollapsedVertex cv,
MultiMap vertices_to_edges,
Set coveredCV)
INTERNAL METHOD |
protected void |
createUndirectedEdge(Graph g,
GraphCollapser.CollapsedVertex superVertex,
Vertex opposite,
Set relevantEdges)
Overridable method to create a single undirected edge that represents the data in its parameters. |
protected MultiMap |
findEdgesAndVerticesConnectedToRootSet(Set rootSet)
INTERNAL METHOD. |
Graph |
getCollapsedGraph(EquivalenceRelation equivalence)
This version collects sets of vertices in an equivalence relation into a single CollapsedVertex. |
Graph |
getCollapsedGraph(Graph g,
Set rootSet)
This function collapses a series of vertices in one EquivalenceSet into one CollapsedVertex. |
static GraphCollapser |
getInstance()
|
protected void |
replaceEquivalencesWithCollapsedVertices(EquivalenceRelation er,
Graph copy,
Map superVertices)
INTERNAL (undocumented) method. |
protected void |
replaceWith(MultiMap m,
Vertex dest,
GraphCollapser.CollapsedVertex superV)
INTERNAL (undocumented) method |
protected boolean |
shouldAddEdge(Vertex opposite,
Set rootSet,
Collection edges)
Overridable method checks whether an edge representing the given set of edges should be created. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static GraphCollapser instance
Constructor Detail |
---|
protected GraphCollapser()
Method Detail |
---|
public static GraphCollapser getInstance()
public Graph getCollapsedGraph(EquivalenceRelation equivalence)
equivalence
- A properly-defined EquivalenceRelation representing DISJOINT sets of vertices from the Graph.
protected void createEdgesCorrespondingToMap(Graph copy, GraphCollapser.CollapsedVertex cv, MultiMap vertices_to_edges, Set coveredCV)
protected void collapseVerticesIntoSuperVertices(EquivalenceRelation er, Map superVertices, MultiMap vertices_to_edges)
er
- superVertices
- vertices_to_edges
- protected void replaceWith(MultiMap m, Vertex dest, GraphCollapser.CollapsedVertex superV)
m
- dest
- superV
- protected void replaceEquivalencesWithCollapsedVertices(EquivalenceRelation er, Graph copy, Map superVertices)
er
- copy
- superVertices
- public Graph getCollapsedGraph(Graph g, Set rootSet)
g
- A graph to collapse vertices fromrootSet
- A set of vertice to collapse into one CollapsedVertex
protected void annotateVertex(GraphCollapser.CollapsedVertex superVertex, Set rootSet)
superVertex
- a new CollapsedVertexrootSet
- a set of Vertexes from the old graph.protected void annotateEdge(GraphCollapser.CollapsedEdge newEdge, Collection edgesFromWhichWeMightDeriveData)
newEdge
- a new CollapsedEdgeedgesFromWhichWeMightDeriveData
- protected GraphCollapser.CollapsedVertex createCollapsedVertex(Graph g, Set rootSet)
g
- The input graphrootSet
- The set of vertices which should be represented by the
new vertex.
protected void createUndirectedEdge(Graph g, GraphCollapser.CollapsedVertex superVertex, Vertex opposite, Set relevantEdges)
g
- The graph in which this edge should be addedopposite
- The vertex at the far end of this edgesuperVertex
- The vertex at the near end of this edge. (For an undirecte
graph, it doesn't really matter).relevantEdges
- The set of edges that this edge is meant to represent.protected void createDirectedEdges(Graph graph, GraphCollapser.CollapsedVertex superVertex, Vertex opposite, Set relevantEdges)
g
- The graph in which this edge should be addedopposite
- The vertex at the far end of this edgesuperVertex
- The vertex at the near end of this edge. (For an undirecte
graph, it doesn't really matter).relevantEdges
- The set of edges that this edge is meant to represent.protected MultiMap findEdgesAndVerticesConnectedToRootSet(Set rootSet)
rootSet
-
protected boolean shouldAddEdge(Vertex opposite, Set rootSet, Collection edges)
opposite
- rootSet
- a set of vertices that currently are one end
of these edges.edges
- a non-empty collection of edges that may be
replaced
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |