edu.uci.ics.jung.algorithms.cluster
Class ClusterSet

java.lang.Object
  extended byedu.uci.ics.jung.algorithms.cluster.ClusterSet
Direct Known Subclasses:
EdgeClusterSet, VertexClusterSet

public abstract class ClusterSet
extends java.lang.Object

A data structure representing the clusters, connected set of vertices (or edges), in a graph. The clusters can be retrieved based upon their position index in the collection. Also, given a vertex (or edge) the corresponding clusters can be retrieved. There is no requirement that the union of the set of vertices (or edges) in each cluster needs to equal the set of all vertices in the graph.

Author:
Scott White

Constructor Summary
ClusterSet(Graph underlyingGraph)
          Creates a new instance.
 
Method Summary
 void addCluster(java.util.Set elements)
          Adds a new cluster to the collection.
abstract  ClusterSet createEquivalentClusterSet(Graph anotherGraph)
          Returns the corresponding cluster set in the other graph.
 java.util.Set getCluster(int index)
          Given the cluster's position in the list (0-based), retrieve the cluster (set of vertices)
abstract  Graph getClusterAsNewSubGraph(int index)
          Constructs a new graph from the given cluster
 java.util.Set getClusters(UserDataContainer element)
          Given a vertex (or edge), retrieves the clusters which that vertex (or edge) belongs to if any
 Graph getUnderlyingGraph()
           
 java.util.Iterator iterator()
          Returns an iterator to the component list.
 int size()
          the size of the cluster collection.
 void sort()
          Sorts the clusters by size.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClusterSet

public ClusterSet(Graph underlyingGraph)
Creates a new instance.

Method Detail

addCluster

public void addCluster(java.util.Set elements)
Adds a new cluster to the collection.

Parameters:
elements - the set of vertices (or edges) comprising a component to be added

getClusterAsNewSubGraph

public abstract Graph getClusterAsNewSubGraph(int index)
Constructs a new graph from the given cluster

Parameters:
index - the position index of the cluster in the collection
Returns:
a new graph representing the cluster

createEquivalentClusterSet

public abstract ClusterSet createEquivalentClusterSet(Graph anotherGraph)
Returns the corresponding cluster set in the other graph. If any of the vertices (or edges) in the specified graph are not equivalent to the corresponding vertices (or edges) in this graph then an IllegalArgumentException is thrown.

Parameters:
anotherGraph - another graph whose corresponding clusters are to be retrieved
Returns:
the set of clsuters for the new graph

getClusters

public java.util.Set getClusters(UserDataContainer element)
Given a vertex (or edge), retrieves the clusters which that vertex (or edge) belongs to if any

Parameters:
element - the vertex (or edge) whose cluster is to be retrieved.
Returns:
the set of clusters (set of non-overlapping vertices (or edges))

getCluster

public java.util.Set getCluster(int index)
Given the cluster's position in the list (0-based), retrieve the cluster (set of vertices)

Parameters:
index - the 0-based index of the cluster in the list.
Returns:
the set of vertices (or edges) comprising the cluster

iterator

public java.util.Iterator iterator()
Returns an iterator to the component list.

Returns:
the iterator to the component list

size

public int size()
the size of the cluster collection.

Returns:
the number of clusters in the collection

sort

public void sort()
Sorts the clusters by size.


getUnderlyingGraph

public Graph getUnderlyingGraph()