INITIAL ISSUE
Good day everybody,
I've already found several algorithms to do this task. The but is that all those codes consider a weight value per node or edge.
My aim is easier than that, It is to get the distance matrix from adjacency one.
The input would be:
a b c d e f connected vertices to i
a 0 1 0 0 0 0 1
b 1 0 1 1 0 0 3
c 0 1 0 0 0 0 1
d 0 1 0 0 1 0 2
e 0 0 0 1 0 1 2
f 0 0 0 0 1 0 1
---
Sum: 10 -> Edges = Sum/2 = 5
The output would be:
a b c d e f
a 0 1 2 2 3 4
b 1 0 1 1 2 3
c 2 1 0 2 3 4
d 2 1 2 0 1 2
e 3 2 3 1 0 1
f 4 3 4 2 1 0
Thanks in advance for any suggestion,
David Alejandro.
SOLUTION FOUND
Floyd-Warshall Kernell in C
for (k = 0; k < n; ++k)
{
for (i = 0; i < n; ++i)
{
for (j = 0; j < n; ++j)
{
if ((dist[i][k] * dist[k][j] != 0) && (i != j))
{
if ((dist[i][k] + dist[k][j] < dist[i][j]) || (dist[i][j] == 0))
{
dist[i][j] = dist[i][k] + dist[k][j];
}
}
}
}
}