Package com.gengoai.graph.clustering
Class ChineseWhispers<V>
- java.lang.Object
-
- com.gengoai.graph.clustering.ChineseWhispers<V>
-
- Type Parameters:
V
- the type parameter
- All Implemented Interfaces:
Clusterer<V>
public class ChineseWhispers<V> extends Object implements Clusterer<V>
Implementation of the Chinese Whispers graph clustering algorithm as outlined in
- Biemann, Chris. "Chinese whispers: an efficient graph clustering algorithm and its application to natural language processing problems." Proceedings of the First Workshop on Graph Based Methods for Natural Language Processing. Association for Computational Linguistics, 2006.
- Author:
- David B. Bracewell
-
-
Constructor Summary
Constructors Constructor Description ChineseWhispers()
Default constructormaxIterations = 10
,acceptanceRate = 1
, andnewClusterRate = 0d
ChineseWhispers(int maxIterations, double acceptanceRate, double newClusterRate)
Initialization constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<Set<V>>
cluster(Graph<V> g)
Clusters the vertices of the given graph and returns a list of clusters (sets).double
getAcceptanceRate()
Gets acceptance rate.int
getMaxIterations()
Gets max iterations.double
getNewClusterRate()
Gets new cluster rate.void
setAcceptanceRate(double acceptanceRate)
Sets acceptance rate.void
setMaxIterations(int maxIterations)
Sets max iterations.void
setNewClusterRate(double newClusterRate)
Sets new cluster rate.
-
-
-
Constructor Detail
-
ChineseWhispers
public ChineseWhispers()
Default constructormaxIterations = 10
,acceptanceRate = 1
, andnewClusterRate = 0d
-
ChineseWhispers
public ChineseWhispers(int maxIterations, double acceptanceRate, double newClusterRate)
Initialization constructor- Parameters:
maxIterations
- The maximum number of iterations to run the clusteringacceptanceRate
- The rate used to determine if a label change should be acceptednewClusterRate
- the new cluster rate
-
-
Method Detail
-
getNewClusterRate
public double getNewClusterRate()
Gets new cluster rate.- Returns:
- the new cluster rate
-
setNewClusterRate
public void setNewClusterRate(double newClusterRate)
Sets new cluster rate.- Parameters:
newClusterRate
- the new cluster rate
-
cluster
public List<Set<V>> cluster(Graph<V> g)
Description copied from interface:Clusterer
Clusters the vertices of the given graph and returns a list of clusters (sets).
-
getMaxIterations
public int getMaxIterations()
Gets max iterations.- Returns:
- the maxIterations
-
setMaxIterations
public void setMaxIterations(int maxIterations)
Sets max iterations.- Parameters:
maxIterations
- the maxIterations to set
-
getAcceptanceRate
public double getAcceptanceRate()
Gets acceptance rate.- Returns:
- the acceptanceRate
-
setAcceptanceRate
public void setAcceptanceRate(double acceptanceRate)
Sets acceptance rate.- Parameters:
acceptanceRate
- the acceptanceRate to set
-
-