18 #include <grass/gis.h>
19 #include <grass/Vect.h>
20 #include <grass/glocale.h>
21 #include <grass/dgl/graph.h>
22 #include <grass/neta.h>
48 for (i = 1; i <= nnodes; i++) {
55 for (i = 0; i < from->n_values; i++) {
56 int v = from->value[i];
89 if (dst[to_id] == -1 || dst[to_id] > dist + d) {
90 dst[to_id] = dist + d;
127 int begin, end, cur, nnodes;
132 vis = (
char *)G_calloc(nnodes + 1,
sizeof(
char));
133 if (!prev || !queue || !vis) {
144 while (begin != end) {
158 if (edges[
id] && !vis[to]) {
174 while (prev[cur] !=
NULL) {
181 return list->n_values;
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 NetA_find_path(dglGraph_s *graph, int from, int to, int *edges, struct ilist *list)
Find a path (minimum number of edges) from 'from' to 'to' using only edges in 'edges'.
void dglHeapFree(dglHeap_s *pheap, dglHeapCancelItem_fn pfnCancelItem)
void dglHeapInit(dglHeap_s *pheap)
int NetA_distance_from_points(dglGraph_s *graph, struct ilist *from, int *dst, dglInt32_t **prev)
Computes shortests paths to every node from nodes in "from".
dglInt32_t dglEdgeGet_Id(dglGraph_s *pGraph, dglInt32_t *pnEdge)
void dglEdgeset_T_Release(dglEdgesetTraverser_s *pT)
dglInt32_t * dglEdgeset_T_First(dglEdgesetTraverser_s *pT)
dglInt32_t * dglGetNode(dglGraph_s *pGraph, dglInt32_t nNodeId)
int Vect_reset_list(struct ilist *list)
Reset ilist structure.
int Vect_list_append(struct ilist *list, int val)
Append new item to the end of list if not yet present.
dglInt32_t * dglEdgeGet_Head(dglGraph_s *pGraph, dglInt32_t *pnEdge)
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.
int dglHeapInsertMin(dglHeap_s *pheap, long key, unsigned char flags, dglHeapData_u value)
int dglHeapExtractMin(dglHeap_s *pheap, dglHeapNode_s *pnoderet)
dglInt32_t * dglEdgeset_T_Next(dglEdgesetTraverser_s *pT)