22 #include <grass/dgl/graph.h>
52 for (i = 1; i <= nnodes; i++) {
62 for (i = 0; i < from->
n_values; i++) {
63 int v = from->
value[i];
89 if (have_node_costs && prev[v]) {
106 if (
dst[to_id] < 0 ||
dst[to_id] > dist + d) {
107 dst[to_id] = dist + d;
109 heap_data.
ul = to_id;
150 for (i = 1; i <= nnodes; i++) {
156 G_warning(
"Directed graph must be version 2 or 3 for "
157 "NetA_distance_to_points()");
166 for (i = 0; i < to->
n_values; i++) {
167 int v = to->
value[i];
187 dist = heap_node.
key;
193 if (have_node_costs && nxt[v]) {
210 if (
dst[from_id] < 0 ||
dst[from_id] > dist + d) {
211 dst[from_id] = dist + d;
213 heap_data.
ul = from_id;
250 int begin, end, cur, nnodes;
257 vis = (
char *)
G_calloc(nnodes + 1,
sizeof(
char));
258 if (!prev || !
queue || !vis) {
272 while (begin != end) {
280 if (have_node_costs && prev[
vertex]) {
295 if (edges[edge_id] && !vis[node_id]) {
297 prev[node_id] = edge;
298 queue[end++] = node_id;
311 while (prev[cur] !=
NULL) {
318 return list->n_values;
void G_free(void *)
Free allocated memory.
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
void G_warning(const char *,...) __attribute__((format(printf
int Vect_list_append(struct ilist *, int)
Append new item to the end of list if not yet present.
int Vect_reset_list(struct ilist *)
Reset ilist structure.
void dglHeapInit(dglHeap_s *pheap)
int dglHeapInsertMin(dglHeap_s *pheap, long key, unsigned char flags, dglHeapData_u value)
void dglHeapFree(dglHeap_s *pheap, dglHeapCancelItem_fn pfnCancelItem)
int dglHeapExtractMin(dglHeap_s *pheap, dglHeapNode_s *pnoderet)
int n_values
Number of values in the list.
int * value
Array of values.
int dglGet_NodeAttrSize(dglGraph_s *pgraph)
dglInt32_t * dglNodeGet_OutEdgeset(dglGraph_s *pGraph, dglInt32_t *pnNode)
int dglEdgeset_T_Initialize(dglEdgesetTraverser_s *pT, dglGraph_s *pGraph, dglInt32_t *pnEdgeset)
dglInt32_t dglEdgeGet_Id(dglGraph_s *pGraph, dglInt32_t *pnEdge)
dglInt32_t * dglEdgeset_T_Next(dglEdgesetTraverser_s *pT)
dglInt32_t * dglEdgeGet_Tail(dglGraph_s *pGraph, dglInt32_t *pnEdge)
dglInt32_t * dglEdgeGet_Head(dglGraph_s *pGraph, dglInt32_t *pnEdge)
dglInt32_t * dglNodeGet_Attr(dglGraph_s *pGraph, dglInt32_t *pnNode)
int dglGet_NodeCount(dglGraph_s *pgraph)
void dglEdgeset_T_Release(dglEdgesetTraverser_s *pT UNUSED)
dglInt32_t * dglNodeGet_InEdgeset(dglGraph_s *pGraph, dglInt32_t *pnNode)
dglInt32_t dglEdgeGet_Cost(dglGraph_s *pGraph, dglInt32_t *pnEdge)
dglInt32_t * dglEdgeset_T_First(dglEdgesetTraverser_s *pT)
dglInt32_t dglNodeGet_Id(dglGraph_s *pGraph, dglInt32_t *pnNode)
dglInt32_t * dglGetNode(dglGraph_s *pGraph, dglInt32_t nNodeId)
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 flagged as valid in 'edges...
int NetA_distance_to_points(dglGraph_s *graph, struct ilist *to, int *dst, dglInt32_t **nxt)
Computes shortest paths from every node to nodes in "to".
int NetA_distance_from_points(dglGraph_s *graph, struct ilist *from, int *dst, dglInt32_t **prev)
Computes shortest paths to every node from nodes in "from".