19 #include <grass/gis.h>
20 #include <grass/Vect.h>
21 #include <grass/glocale.h>
22 #include <grass/dgl/graph.h>
40 int nnodes, i, j, k, indices;
53 G_message(_(
"Computing all pairs shortest paths..."));
55 for (i = 0; i <= nnodes; i++)
56 for (j = 0; j <= nnodes; j++)
63 node_indices[indices++] = node_id;
77 for (k = 0; k < indices; k++) {
81 for (i = 0; i < indices; i++) {
84 if (dist[i_index][k_index] == -1)
86 for (j = 0; j < indices; j++) {
89 if (dist[k_index][j_index] != -1 &&
90 (dist[i_index][k_index] + dist[k_index][j_index] <
91 dist[i_index][j_index] ||
92 dist[i_index][j_index] == -1)) {
93 dist[i_index][j_index] =
94 dist[i_index][k_index] + dist[k_index][j_index];