public class VoltageClusterer<V,E>
extends java.lang.Object
Clusters vertices of a Graph
based on their ranks as
calculated by VoltageScorer
. This algorithm is based on,
but not identical with, the method described in the paper below.
The primary difference is that Wu and Huberman assume a priori that the clusters
are of approximately the same size, and therefore use a more complex
method than k-means (which is used here) for determining cluster
membership based on co-occurrence data.
The algorithm proceeds as follows:
NOTE: Depending on how the co-occurrence data splits the data into clusters, the number of clusters returned by this algorithm may be less than the number of clusters requested. The number of clusters will never be more than the number requested, however.
VoltageScorer
,
KMeansClusterer
Modifier and Type | Class and Description |
---|---|
protected class |
VoltageClusterer.MapValueArrayComparator |
Modifier and Type | Field and Description |
---|---|
protected edu.uci.ics.jung.graph.Graph<V,E> |
g |
protected KMeansClusterer<V> |
kmc |
protected int |
num_candidates |
protected java.util.Random |
rand |
Constructor and Description |
---|
VoltageClusterer(edu.uci.ics.jung.graph.Graph<V,E> g,
int num_candidates)
Creates an instance of a VoltageCluster with the specified parameters.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addOneCandidateCluster(java.util.LinkedList<java.util.Set<V>> candidates,
java.util.Map<V,double[]> voltage_ranks)
alternative to addTwoCandidateClusters(): cluster vertices by voltages into 2 clusters.
|
protected void |
addTwoCandidateClusters(java.util.LinkedList<java.util.Set<V>> candidates,
java.util.Map<V,double[]> voltage_ranks)
Do k-means with three intervals and pick the
smaller two clusters (presumed to be on the ends); this is closer to the Wu-Huberman method.
|
protected java.util.Collection<java.util.Set<V>> |
cluster_internal(V origin,
int num_clusters)
Does the work of
getCommunity and cluster . |
java.util.Collection<java.util.Set<V>> |
cluster(int num_clusters)
Clusters the vertices of
g into
num_clusters clusters, based on their connectivity. |
java.util.Collection<java.util.Set<V>> |
getCommunity(V v)
Returns a community (cluster) centered around
v . |
protected java.util.Map<V,double[]> |
getObjectCounts(java.util.Collection<java.util.Set<V>> candidates,
V seed) |
protected java.util.List<V> |
getSeedCandidates(java.util.Collection<java.util.Set<V>> candidates)
Returns an array of cluster seeds, ranked in decreasing order
of number of appearances in the specified collection of candidate
clusters.
|
protected void |
setRandomSeed(int random_seed) |
protected int num_candidates
protected KMeansClusterer<V> kmc
protected java.util.Random rand
public VoltageClusterer(edu.uci.ics.jung.graph.Graph<V,E> g, int num_candidates)
num_candidates
- the number of candidate clusters to createprotected void setRandomSeed(int random_seed)
public java.util.Collection<java.util.Set<V>> getCommunity(V v)
v
.v
- the vertex whose community we wish to discoverpublic java.util.Collection<java.util.Set<V>> cluster(int num_clusters)
g
into
num_clusters
clusters, based on their connectivity.num_clusters
- the number of clusters to identifyprotected java.util.Collection<java.util.Set<V>> cluster_internal(V origin, int num_clusters)
getCommunity
and cluster
.origin
- the vertex around which clustering is to be donenum_clusters
- the (maximum) number of clusters to findprotected void addTwoCandidateClusters(java.util.LinkedList<java.util.Set<V>> candidates, java.util.Map<V,double[]> voltage_ranks)
candidates
- voltage_ranks
- protected void addOneCandidateCluster(java.util.LinkedList<java.util.Set<V>> candidates, java.util.Map<V,double[]> voltage_ranks)
candidates
- voltage_ranks
- protected java.util.List<V> getSeedCandidates(java.util.Collection<java.util.Set<V>> candidates)
candidates
-