This is an implementation of the Chinese Whispers clustering algorithm in Python. Since this library is based on NetworkX, it is simple to use.
Given a NetworkX graph G
, this library can cluster it using the following code:
from chinese_whispers import chinese_whispers
chinese_whispers(G, weighting='top', iterations=20)
As the result, each node of the input graph is provided with the label
attribute that stores the cluster label.
More usage examples are available in the sample notebook.
In case you require higher performance, please consider our Java implementation that also includes other graph clustering algorithms: https://github.com/nlpub/watset-java.