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];
dglInt32_t * dglEdgeGet_Tail(dglGraph_s *pGraph, dglInt32_t *pnEdge)
dglInt32_t dglNodeGet_Id(dglGraph_s *pGraph, dglInt32_t *pnNode)
void G_free(void *buf)
Free allocated memory.
int dglEdgeset_T_Initialize(dglEdgesetTraverser_s *pT, dglGraph_s *pGraph, dglInt32_t *pnEdgeset)
int dglNode_T_Initialize(dglNodeTraverser_s *pT, dglGraph_s *pGraph)
void dglNode_T_Release(dglNodeTraverser_s *pT)
dglInt32_t dglEdgeGet_Id(dglGraph_s *pGraph, dglInt32_t *pnEdge)
int G_percent(long n, long d, int s)
Print percent complete messages.
void dglEdgeset_T_Release(dglEdgesetTraverser_s *pT)
int G_percent_reset(void)
Reset G_percent() to 0%; do not add newline.
dglInt32_t * dglEdgeset_T_First(dglEdgesetTraverser_s *pT)
void G_message(const char *msg,...)
Print a message to stderr.
dglInt32_t * dglNode_T_First(dglNodeTraverser_s *pT)
dglInt32_t * dglNodeGet_OutEdgeset(dglGraph_s *pGraph, dglInt32_t *pnNode)
dglInt32_t dglEdgeGet_Cost(dglGraph_s *pGraph, dglInt32_t *pnEdge)
int dglGet_NodeCount(dglGraph_s *pgraph)
int G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
dglInt32_t * dglNode_T_Next(dglNodeTraverser_s *pT)
int NetA_allpairs(dglGraph_s *graph, dglInt32_t **dist)
Stores the directed distance between every pair.
dglInt32_t * dglEdgeset_T_Next(dglEdgesetTraverser_s *pT)