Floyd-Warshall Algorithm

If you want to find the length of node and shorthest path in a graph we can use Floyd-Warshall Algorithm

`
int [][] map = new int[n][n];
for (int i = 0; i < n; i++) {
Arrays.fill(map[i], Integer.MAX_VALUE/2);
}
for (int i = 0; i < n; i++) {
map[i][i] = 0;
}
for (int i = 0; i < a.length; i++) {
map[a[i]-1][b[i]-1] = len[i];
map[b[i]-1][a[i]-1] = len[i];
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
for (int j2 = 0; j2 < n; j2++) {
map[j][j2] = Math.min(map[j][j2], map[j][i] + map[i][j2]);
}
}

    }

`

You can see the explanation in here : http://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm

 
0
Kudos
 
0
Kudos

Now read this

Cosine Similarity

As you know, to measure similarity between 2 dataset can use several way, maybe you are familiar with Pearson Correlation, Pearson Correlation is a measure two dataset by measuring their Eucledian Distance or the minimum distance.... Continue →