An Efficient Graph Clustering Algorithm for Node.js
Picture credit: http://www.wikihow.com/Play-Chinese-Whispers
Chinese Whispers - an Efficient Graph Clustering Algorithm and its Application to Natural Language Processing Problems
npm install chinese-whispers
Talk is cheap, show me the code!
for in clusterIndicesList// Cluster: 0,1,2// Cluster: 10,11,12// Cluster: 20,21,22
Source code can be found at: https://github.com/zixia/chinese-whispers/blob/master/examples/demo.ts
ChineseWhispers class is all you need to run the Chinese Whispers Algorithm.
weightFunc: a function that takes two data item, calculate the weight between them and return the value.
epochs: how many epoches to run the algorithm, default 15.
threshold: minimum weight required for a edge. default 0.
// calculate the distance between vectors
dataList which is an array of data, returns the cluster results as an array, each array item is a cluster, and each cluster is an array which includes the indices of dataList that belongs to this cluster.
for in clusterIndicesList
The code is heavily inspired by the following implementation:
Huan LI <firstname.lastname@example.org> (http://linkedin.com/in/zixia)