我經歷過的馬爾可夫聚類算法的細節下面的示例工作:馬爾可夫聚類算法
http://www.cs.ucsb.edu/~xyan/classes/CS595D-2009winter/MCL_Presentation2.pdf
我覺得我已經準確地代表的算法,但我沒有得到相同的結果至少,本指南正在爲此提供意見。
當前的代碼是: http://jsfiddle.net/methodin/CtGJ9/
我不知道,也許我剛纔錯過了一個小的事實,或者只需要一個小的調整,地方對於這一點,但我已經嘗試了一些變化,包括:
- 交換通貨膨脹/擴展
- 基於精密
- 卸下正常化(因爲原來的引導並不需要它檢查平等,雖然官方MCL d ocumentation狀態以在每次通過時對矩陣進行歸一化)
所有這些都返回了相同的結果 - 節點隻影響自身。
我甚至發現,在VB類似的算法實現: http://mcl.codeplex.com/SourceControl/changeset/changes/17748#MCL%2fMCL%2fMatrix.vb
而且我的代碼似乎與他們的編號(600 - 例如距離)以外匹配。
這是擴展功能
// Take the (power)th power of the matrix effectively multiplying it with
// itself pow times
this.matrixExpand = function(matrix, pow) {
var resultMatrix = [];
for(var row=0;row<matrix.length;row++) {
resultMatrix[row] = [];
for(var col=0;col<matrix.length;col++) {
var result = 0;
for(var c=0;c<matrix.length;c++)
result += matrix[row][c] * matrix[c][col];
resultMatrix[row][col] = result;
}
}
return resultMatrix;
};
這是充氣功能
// Applies a power of X to each item in the matrix
this.matrixInflate = function(matrix, pow) {
for(var row=0;row<matrix.length;row++)
for(var col=0;col<matrix.length;col++)
matrix[row][col] = Math.pow(matrix[row][col], pow);
};
最後主中繼功能
// Girvan–Newman algorithm
this.getMarkovCluster = function(power, inflation) {
var lastMatrix = [];
var currentMatrix = this.getAssociatedMatrix();
this.print(currentMatrix);
this.normalize(currentMatrix);
currentMatrix = this.matrixExpand(currentMatrix, power);
this.matrixInflate(currentMatrix, inflation);
this.normalize(currentMatrix);
while(!this.equals(currentMatrix,lastMatrix)) {
lastMatrix = currentMatrix.slice(0);
currentMatrix = this.matrixExpand(currentMatrix, power);
this.matrixInflate(currentMatrix, inflation);
this.normalize(currentMatrix);
}
return currentMatrix;
};
jsfiddle鏈接似乎被打破,你的實現仍然可用的地方?謝謝! – skyork 2013-07-22 15:06:24
奇怪。我想知道它去了哪裏?這是代碼的要點:https://gist.github.com/methodin/1573728 – methodin 2013-07-22 17:11:25
這裏是一個codepen:http://codepen.io/Xeoncross/pen/NqWqWe?editors=101 – Xeoncross 2015-04-21 15:51:51