public abstract class CPMClusteringAlgorithm extends java.lang.Object implements java.lang.Cloneable, QualityClusteringAlgorithm
Modifier and Type | Field and Description |
---|---|
static double |
DEFAULT_RESOLUTION
Default resolution parameter.
|
protected double |
resolution
Resolution parameter.
|
Constructor and Description |
---|
CPMClusteringAlgorithm()
Constructs a CPM clustering algorithm.
|
CPMClusteringAlgorithm(double resolution)
Constructs a CPM clustering algorithm with a specified resolution
parameter.
|
Modifier and Type | Method and Description |
---|---|
double |
calcQuality(Network network,
Clustering clustering)
Calculates the quality of a clustering using the CPM quality function.
|
CPMClusteringAlgorithm |
clone()
Clones the algorithm.
|
double |
getResolution()
Returns the resolution parameter.
|
int |
removeCluster(Network network,
Clustering clustering,
int cluster)
Removes a cluster from a clustering by merging the cluster with another
cluster.
|
boolean |
removeSmallClustersBasedOnNNodes(Network network,
Clustering clustering,
int minNNodesPerCluster)
Removes small clusters from a clustering.
|
boolean |
removeSmallClustersBasedOnWeight(Network network,
Clustering clustering,
double minClusterWeight)
Removes small clusters from a clustering.
|
void |
setResolution(double resolution)
Sets the resolution parameter.
|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
findClustering
public static final double DEFAULT_RESOLUTION
protected double resolution
public CPMClusteringAlgorithm()
public CPMClusteringAlgorithm(double resolution)
resolution
- Resolution parameterpublic CPMClusteringAlgorithm clone()
clone
in class java.lang.Object
public double getResolution()
public void setResolution(double resolution)
resolution
- Resolution parameterpublic double calcQuality(Network network, Clustering clustering)
The CPM quality function is given by
1 / (2 * m) * sum(d(c[i], c[j]) * (a[i][j] - resolution * n[i] *
n[j]))
,
where a[i][j]
is the weight of the edge between nodes i
and j
, n[i]
is the weight of node i
, m
is the total edge weight, and resolution
is the resolution
parameter. The function d(c[i], c[j])
equals 1 if nodes i
and j
belong to the same cluster and 0 otherwise. The sum is
taken over all pairs of nodes i
and j
.
Modularity can be expressed in terms of CPM by setting n[i]
equal to the total weight of the edges between node i
and its
neighbors and by rescaling the resolution parameter by 2 * m
.
calcQuality
in interface QualityClusteringAlgorithm
network
- Networkclustering
- Clusteringpublic int removeCluster(Network network, Clustering clustering, int cluster)
network
- Networkclustering
- Clusteringcluster
- Cluster to be removedpublic boolean removeSmallClustersBasedOnNNodes(Network network, Clustering clustering, int minNNodesPerCluster)
network
- Networkclustering
- ClusteringminNNodesPerCluster
- Minimum number of nodes per clusterpublic boolean removeSmallClustersBasedOnWeight(Network network, Clustering clustering, double minClusterWeight)
The total node weight of a cluster equals the sum of the weights of the nodes belonging to the cluster.
network
- Networkclustering
- ClusteringminClusterWeight
- Minimum total node weight of a cluster