edu.uci.ics.jung.graph.impl
Class HypergraphBPG

java.lang.Object
  extended byedu.uci.ics.jung.utils.UserData
      extended byedu.uci.ics.jung.graph.impl.AbstractArchetypeGraph
          extended byedu.uci.ics.jung.graph.impl.HypergraphBPG
All Implemented Interfaces:
ArchetypeGraph, java.lang.Cloneable, Hypergraph, UserDataContainer

public class HypergraphBPG
extends AbstractArchetypeGraph
implements Hypergraph

Implements a hypergraph built over an underlying Bipartite graph, using the equivalence explained in the FAQ. Fully implements the Hypergraph interface; its vertices and edges fully implement their interfaces. Use and create in the standard way; the underlying graph is invisible to the user (but can be extracted with a call to getBipartiteGraphEquivalent() ).

Author:
danyelf

Nested Class Summary
 
Nested classes inherited from class edu.uci.ics.jung.utils.UserDataContainer
UserDataContainer.CopyAction
 
Field Summary
static BipartiteGraph.Choice EDGE
           
static BipartiteGraph.Choice VERTEX
           
 
Fields inherited from class edu.uci.ics.jung.utils.UserData
CLONE, REMOVE, SHARED
 
Fields inherited from interface edu.uci.ics.jung.graph.ArchetypeGraph
SUBSET_MANAGER
 
Constructor Summary
HypergraphBPG()
           
 
Method Summary
 Hyperedge addEdge(Hyperedge e)
          Adds a single edge to the graph
 void addUserDatum(java.lang.Object key, java.lang.Object datum, UserDataContainer.CopyAction copyAct)
          Adds the specified data with the specified key to this object's user data repository, with the specified CopyAction.
 Hypervertex addVertex(Hypervertex v)
           
 ArchetypeGraph copy()
          Performs a deep copy of the graph and its contents.
 BipartiteGraph getBipartiteGraphEquivalent()
          Returns a BipartiteGraph equivalent to this Graph.
 ArchetypeEdge getEdgeCorrespondingTo(BipartiteVertex vertex2)
           
 java.util.Set getEdges()
          Returns the set of all edges in the graph.
 java.lang.Object getUserDatum(java.lang.Object key)
          Retrieves the object in this object's user data repository to which key refers.
 UserDataContainer.CopyAction getUserDatumCopyAction(java.lang.Object key)
          Retrieves the CopyAction for the object stored in this object's user data repository to which key refers.
 java.util.Iterator getUserDatumKeyIterator()
          Provides an iterator over this object's user data repository key set.
 ArchetypeVertex getVertexCorrespondingTo(BipartiteVertex vertex2)
           
 java.util.Set getVertices()
          Returns a set of all the vertices in the graph.
 void importUserData(UserDataContainer udc)
          Takes the user data stored in udc and copies it to this object's user data repository, respecting each datum's CopyAction.
 ArchetypeGraph newInstance()
          Returns a graph of the same type as the graph on which this method is invoked.
 int numEdges()
          Returns a count of the number of edges in the graph.
 int numVertices()
          Returns a count of the number of vertices in the graph.
 void removeAllEdges()
          Removes all edges from this graph, leaving the vertices intact.
 void removeAllVertices()
          Removes all vertices (and, therefore, edges) from this graph.
 void removeEdge(ArchetypeEdge e)
           
 void removeEdges(java.util.Set edges)
          Removes all elements of edges from this graph.
 java.lang.Object removeUserDatum(java.lang.Object key)
          Retrieves the object in this object's user data repository to which key refers, and removes it from the repository.
 void removeVertex(ArchetypeVertex v)
           
 void removeVertices(java.util.Set vertices)
          Removes all elements of vertices from this graph.
 void setUserDatum(java.lang.Object key, java.lang.Object datum, UserDataContainer.CopyAction copyAct)
          If key refers to an existing user datum in this object's repository, that datum is replaced by the specified datum.
 
Methods inherited from class edu.uci.ics.jung.graph.impl.AbstractArchetypeGraph
addListener, getEdgeConstraints, getVertexConstraints, removeListener, toString
 
Methods inherited from class edu.uci.ics.jung.utils.UserData
containsUserDatumKey
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.uci.ics.jung.graph.ArchetypeGraph
addListener, getEdgeConstraints, getVertexConstraints, removeListener
 
Methods inherited from interface edu.uci.ics.jung.utils.UserDataContainer
containsUserDatumKey
 

Field Detail

VERTEX

public static final BipartiteGraph.Choice VERTEX

EDGE

public static final BipartiteGraph.Choice EDGE
Constructor Detail

HypergraphBPG

public HypergraphBPG()
Method Detail

newInstance

public ArchetypeGraph newInstance()
Description copied from interface: ArchetypeGraph
Returns a graph of the same type as the graph on which this method is invoked.

Specified by:
newInstance in interface ArchetypeGraph
Overrides:
newInstance in class AbstractArchetypeGraph
See Also:
ArchetypeGraph.newInstance()

addVertex

public Hypervertex addVertex(Hypervertex v)
Specified by:
addVertex in interface Hypergraph
Parameters:
v -
See Also:
edu.uci.ics.jung.graph.ArchetypeGraph#addVertex(edu.uci.ics.jung.graph.ArchetypeVertex)

addEdge

public Hyperedge addEdge(Hyperedge e)
Adds a single edge to the graph

Specified by:
addEdge in interface Hypergraph
Parameters:
e -
See Also:
Hypergraph.addEdge(edu.uci.ics.jung.graph.Hyperedge)

getVertices

public java.util.Set getVertices()
Returns a set of all the vertices in the graph.

Specified by:
getVertices in interface ArchetypeGraph
See Also:
ArchetypeGraph.getVertices()

getEdges

public java.util.Set getEdges()
Returns the set of all edges in the graph.

Specified by:
getEdges in interface ArchetypeGraph
See Also:
ArchetypeGraph.getEdges()

numVertices

public int numVertices()
Returns a count of the number of vertices in the graph.

Specified by:
numVertices in interface ArchetypeGraph
Overrides:
numVertices in class AbstractArchetypeGraph
See Also:
ArchetypeGraph.numVertices()

numEdges

public int numEdges()
Returns a count of the number of edges in the graph.

Specified by:
numEdges in interface ArchetypeGraph
Overrides:
numEdges in class AbstractArchetypeGraph
See Also:
ArchetypeGraph.numEdges()

removeVertex

public void removeVertex(ArchetypeVertex v)

removeEdge

public void removeEdge(ArchetypeEdge e)

removeVertices

public void removeVertices(java.util.Set vertices)
Description copied from interface: ArchetypeGraph
Removes all elements of vertices from this graph. If any element of vertices is not part of this graph, then throws IllegalArgumentException. If this exception is thrown, any vertices that may have been removed already are not guaranteed to be restored to the graph. Prunes any resultant ill-formed edges.

Specified by:
removeVertices in interface ArchetypeGraph
Parameters:
vertices - the set of vertices to be removed
See Also:
ArchetypeGraph.removeVertices(java.util.Set)

removeEdges

public void removeEdges(java.util.Set edges)
Description copied from interface: ArchetypeGraph
Removes all elements of edges from this graph. If any element of edges is not part of this graph, then throws IllegalArgumentException. If this exception is thrown, any edges that may have been removed already are not guaranteed to be restored to the graph.

Specified by:
removeEdges in interface ArchetypeGraph
See Also:
ArchetypeGraph.removeEdges(java.util.Set)

removeAllEdges

public void removeAllEdges()
Description copied from interface: ArchetypeGraph
Removes all edges from this graph, leaving the vertices intact. Equivalent to removeEdges(getEdges()).

Specified by:
removeAllEdges in interface ArchetypeGraph
See Also:
ArchetypeGraph.removeAllEdges()

removeAllVertices

public void removeAllVertices()
Description copied from interface: ArchetypeGraph
Removes all vertices (and, therefore, edges) from this graph. Equivalent to removeVertices(getVertices()).

Specified by:
removeAllVertices in interface ArchetypeGraph
See Also:
ArchetypeGraph.removeAllVertices()

copy

public ArchetypeGraph copy()
Description copied from interface: ArchetypeGraph
Performs a deep copy of the graph and its contents.

Specified by:
copy in interface ArchetypeGraph
Overrides:
copy in class AbstractArchetypeGraph
See Also:
ArchetypeGraph.copy()

addUserDatum

public void addUserDatum(java.lang.Object key,
                         java.lang.Object datum,
                         UserDataContainer.CopyAction copyAct)
Description copied from interface: UserDataContainer
Adds the specified data with the specified key to this object's user data repository, with the specified CopyAction.

Specified by:
addUserDatum in interface UserDataContainer
Overrides:
addUserDatum in class UserData
Parameters:
key - A unique (per type, not per node) key into the information
datum - The extended information associated with the node
See Also:
UserDataContainer.addUserDatum(java.lang.Object, java.lang.Object, edu.uci.ics.jung.utils.UserDataContainer.CopyAction)

importUserData

public void importUserData(UserDataContainer udc)
Description copied from interface: UserDataContainer
Takes the user data stored in udc and copies it to this object's user data repository, respecting each datum's CopyAction.

Specified by:
importUserData in interface UserDataContainer
Overrides:
importUserData in class UserData
Parameters:
udc - The UserDataContainer whose user data is being imported
See Also:
UserDataContainer.importUserData(edu.uci.ics.jung.utils.UserDataContainer)

getUserDatumKeyIterator

public java.util.Iterator getUserDatumKeyIterator()
Description copied from interface: UserDataContainer
Provides an iterator over this object's user data repository key set.

Specified by:
getUserDatumKeyIterator in interface UserDataContainer
Overrides:
getUserDatumKeyIterator in class UserData
Returns:
Iterator
See Also:
UserDataContainer.getUserDatumKeyIterator()

getUserDatumCopyAction

public UserDataContainer.CopyAction getUserDatumCopyAction(java.lang.Object key)
Description copied from interface: UserDataContainer
Retrieves the CopyAction for the object stored in this object's user data repository to which key refers.

Specified by:
getUserDatumCopyAction in interface UserDataContainer
Overrides:
getUserDatumCopyAction in class UserData
Parameters:
key -
Returns:
CopyAction
See Also:
UserDataContainer.getUserDatumCopyAction(java.lang.Object)

getUserDatum

public java.lang.Object getUserDatum(java.lang.Object key)
Description copied from interface: UserDataContainer
Retrieves the object in this object's user data repository to which key refers.

Specified by:
getUserDatum in interface UserDataContainer
Overrides:
getUserDatum in class UserData
Parameters:
key -
See Also:
UserDataContainer.getUserDatum(java.lang.Object)

setUserDatum

public void setUserDatum(java.lang.Object key,
                         java.lang.Object datum,
                         UserDataContainer.CopyAction copyAct)
Description copied from interface: UserDataContainer
If key refers to an existing user datum in this object's repository, that datum is replaced by the specified datum. Otherwise this is equivalent to addUserDatum(key, data, copyAct).

Specified by:
setUserDatum in interface UserDataContainer
Overrides:
setUserDatum in class UserData
Parameters:
key -
datum -
See Also:
UserDataContainer.setUserDatum(java.lang.Object, java.lang.Object, edu.uci.ics.jung.utils.UserDataContainer.CopyAction)

removeUserDatum

public java.lang.Object removeUserDatum(java.lang.Object key)
Description copied from interface: UserDataContainer
Retrieves the object in this object's user data repository to which key refers, and removes it from the repository.

Specified by:
removeUserDatum in interface UserDataContainer
Overrides:
removeUserDatum in class UserData
Parameters:
key -
See Also:
UserDataContainer.removeUserDatum(java.lang.Object)

getVertexCorrespondingTo

public ArchetypeVertex getVertexCorrespondingTo(BipartiteVertex vertex2)
Parameters:
vertex2 -
Returns:
the vertex in the hypergraph corresponding to the underlying bipartite vertex vertex2

getEdgeCorrespondingTo

public ArchetypeEdge getEdgeCorrespondingTo(BipartiteVertex vertex2)
Parameters:
vertex2 -
Returns:
the edge in the hypergraph corresponding to the underlying bipartite vertex vertex2

getBipartiteGraphEquivalent

public BipartiteGraph getBipartiteGraphEquivalent()
Returns a BipartiteGraph equivalent to this Graph. Each vertex in the BipartiteGraph will be Equal to a HyperVertex or a HyperEdge in this graph. (Note that equals is NOT symmetrical in this case; hyperedge.equals( vertex ) will return true for one of these vertices, but vertex.equals( hyperedge ) will return false.