Class 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 Detail

      • ChineseWhispers

        public ChineseWhispers()
        Default constructor maxIterations = 10, acceptanceRate = 1, and newClusterRate = 0d
      • ChineseWhispers

        public ChineseWhispers​(int maxIterations,
                               double acceptanceRate,
                               double newClusterRate)
        Initialization constructor
        Parameters:
        maxIterations - The maximum number of iterations to run the clustering
        acceptanceRate - The rate used to determine if a label change should be accepted
        newClusterRate - 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).
        Specified by:
        cluster in interface Clusterer<V>
        Parameters:
        g - the graph
        Returns:
        the clusters
      • 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