public class BipartiteGraph extends UndirectedSparseGraph
Vertices can only be added to the graph with a flag that says which class they will be added to (using BipartiteGraph.Choice ); edges must be of type BipartiteGraph, which must consist of two vertices, one each from CLASSA and CLASSB.
BipartiteGraph bpg = new BipartiteGraph; Vertex va = bpg.addVertex( new UndirectedSparseVertex(), BipartiteGraph.CLASSA ); Vertex vb = bpg.addVertex( new UndirectedSparseVertex(), BipartiteGraph.CLASSB ); bpg.addBipartiteEdge( new BipartiteEdge( va, vb ));Note that the traditional addVertex() and addEdge() will both throw a FatalException.
The function fold creates an UndirectedGraph based on finding vertices that share a common neighbor.
Modifier and Type | Class and Description |
---|---|
static class |
BipartiteGraph.Choice
This small enumerated type merely forces a user to pick class "A"
or "B" when adding a Vertex to a BipartiteGraph.
|
AbstractArchetypeGraph.Requirements
UserDataContainer.CopyAction
Modifier and Type | Field and Description |
---|---|
static java.lang.Object |
BIPARTITE_USER_TAG
The tag for the UserData attached to a single Edge.
|
static BipartiteGraph.Choice |
CLASSA |
static BipartiteGraph.Choice |
CLASSB |
mEdges, mVertices
edge_requirements, mEdgeIDs, mGraphListenerHandler, mVertexIDs, vertex_requirements
factory, udc_delegate
DIRECTED_EDGE, NOT_PARALLEL_EDGE, SIMPLE_EDGE, UNDIRECTED_EDGE
SUBSET_MANAGER
Constructor and Description |
---|
BipartiteGraph() |
Modifier and Type | Method and Description |
---|---|
BipartiteEdge |
addBipartiteEdge(BipartiteEdge bpe)
Adds a BipartiteEdge to the Graph.
|
Edge |
addEdge(Edge ae)
Deprecated.
Use addBipartiteEdge
|
BipartiteVertex |
addVertex(BipartiteVertex v,
BipartiteGraph.Choice choice)
Adds a single vertex to the graph in the specified partition.
|
Vertex |
addVertex(Vertex av)
Deprecated.
Use addBipartiteVertex
|
static Graph |
fold(BipartiteGraph bpg,
BipartiteGraph.Choice vertexSet)
Creates a one-part graph from a bipartite graph by folding
Vertices from one class into a second class.
|
java.util.Set |
getAllVertices(BipartiteGraph.Choice choice)
Returns the set of all vertices from that class.
|
BipartiteGraph.Choice |
getPartition(BipartiteVertex v)
Returns the partition for vertex
v . |
void |
initialize()
Initializes all of the graph's internal data structures.
|
void |
removeVertex(Vertex v)
Removes all edges adjacent to the specified vertex, removes the vertex,
and notifies the vertex that it has been removed.
|
getEdges, getVertices, isDirected, removeEdge, removeEdges, removeVertices
addAllNotInitializers, addListener, checkConstraints, copy, getEdgeConstraints, getVertexConstraints, listenersExist, newInstance, numEdges, numVertices, removeAllEdges, removeAllVertices, removeListener, toString
addUserDatum, clone, containsUserDatumKey, getUserDatum, getUserDatumCopyAction, getUserDatumKeyIterator, importUserData, removeUserDatum, setUserDataFactory, setUserDatum
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
isDirected, removeEdge
addListener, copy, getEdgeConstraints, getEdges, getVertexConstraints, getVertices, newInstance, numEdges, numVertices, removeAllEdges, removeAllVertices, removeEdges, removeListener, removeVertices
addUserDatum, clone, containsUserDatumKey, getUserDatum, getUserDatumCopyAction, getUserDatumKeyIterator, importUserData, removeUserDatum, setUserDatum
public static final BipartiteGraph.Choice CLASSA
public static final BipartiteGraph.Choice CLASSB
public static final java.lang.Object BIPARTITE_USER_TAG
public void initialize()
AbstractArchetypeGraph
Note: this method is not a substitute for
removeAllVertices()
, as it will not notify the vertices
and edges that they have been removed from the graph.
initialize
in class AbstractSparseGraph
public java.util.Set getAllVertices(BipartiteGraph.Choice choice)
public BipartiteGraph.Choice getPartition(BipartiteVertex v)
v
.v
- public BipartiteVertex addVertex(BipartiteVertex v, BipartiteGraph.Choice choice)
Throws an IllegalArgumentException
if v
is not an element of either partition.
v
- the vertex to be added to the classchoice
- the class to which the vertex should be addedpublic BipartiteEdge addBipartiteEdge(BipartiteEdge bpe)
bpe
- a BipartiteEdgepublic Edge addEdge(Edge ae)
addEdge
in interface Graph
addEdge
in class AbstractSparseGraph
ae
- the edge to be addedAbstractSparseGraph.addEdge(edu.uci.ics.jung.graph.Edge)
public Vertex addVertex(Vertex av)
addVertex
in interface Graph
addVertex
in class AbstractSparseGraph
av
- the vertex to be addedAbstractSparseGraph.addVertex(edu.uci.ics.jung.graph.Vertex)
public static Graph fold(BipartiteGraph bpg, BipartiteGraph.Choice vertexSet)
bpg
- The bipartite graph to be foldedvertexSet
- Chooses the set of vertices to be brought into
the new Graph.public void removeVertex(Vertex v)
AbstractSparseGraph
AbstractSparseVertex
.removeVertex
in interface Graph
removeVertex
in class AbstractSparseGraph