24 #include <grass/gis.h>
25 #include <grass/dbmi.h>
26 #include <grass/Vect.h>
27 #include <grass/glocale.h>
42 G_debug(3,
" Edge = %d NodeFrom = %d NodeTo = %d edge cost = %d",
47 if (from != From_node) {
56 G_debug(3,
" EdgeCost += %d (node)", (
int)cost);
62 G_debug(3,
" don't clip first node");
79 { 360000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
81 G_debug(3,
"Vect_graph_init()");
106 G_debug(3,
"Vect_graph_build()");
134 G_debug(3,
"Vect_add_edge() from = %d to = %d, costs = %f, id = %d", from,
164 G_debug(3,
"Vect_graph_set_node_costs()");
192 int i, line, *pclip, cArc, nRet;
196 G_debug(3,
"Vect_graph_shortest_path(): from = %d, to = %d", from, to);
227 *cost = PORT_DOUBLE_MAX;
236 for (i = 0; i < pSPReport->
cArc; i++) {
238 G_debug(2,
"From %ld to %ld - cost %ld user %d distance %ld",
249 *cost = (double)pSPReport->
nDistance / 1000;
251 *cost = (
double)nDistance / 1000;
255 cArc = pSPReport->
cArc;
dglInt32_t dglNodeGet_Id(dglGraph_s *pGraph, dglInt32_t *pnNode)
int dglShortestPath(dglGraph_s *pGraph, dglSPReport_s **ppReport, dglInt32_t nStart, dglInt32_t nDestination, dglSPClip_fn fnClip, void *pvClipArg, dglSPCache_s *pCache)
int Vect_graph_shortest_path(GRAPH *graph, int from, int to, struct ilist *List, double *cost)
Find shortest path.
int dglAddEdge(dglGraph_s *pGraph, dglInt32_t nHead, dglInt32_t nTail, dglInt32_t nCost, dglInt32_t nEdge)
void Vect_graph_add_edge(GRAPH *graph, int from, int to, double costs, int id)
Add edge to graph.
void Vect_graph_set_node_costs(GRAPH *graph, int node, double costs)
Set node costs.
void Vect_graph_init(GRAPH *graph, int nodes_costs)
Initialize graph structure.
int dglShortestDistance(dglGraph_s *pGraph, dglInt32_t *pnDistance, dglInt32_t nStart, dglInt32_t nDestination, dglSPClip_fn fnClip, void *pvClipArg, dglSPCache_s *pCache)
int dglGet_NodeAttrSize(dglGraph_s *pgraph)
dglInt32_t dglEdgeGet_Id(dglGraph_s *pGraph, dglInt32_t *pnEdge)
dglInt32_t * dglGetNode(dglGraph_s *pGraph, dglInt32_t nNodeId)
void dglNodeSet_Attr(dglGraph_s *pGraph, dglInt32_t *pnNode, dglInt32_t *pnAttr)
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 * dglNodeGet_Attr(dglGraph_s *pGraph, dglInt32_t *pnNode)
G_warning("category support for [%s] in mapset [%s] %s", name, mapset, type)
int dglInitialize(dglGraph_s *pGraph, dglByte_t Version, dglInt32_t NodeAttrSize, dglInt32_t EdgeAttrSize, dglInt32_t *pOpaqueSet)
int G_debug(int level, const char *msg,...)
Print debugging message.
dglInt32_t dglEdgeGet_Cost(dglGraph_s *pGraph, dglInt32_t *pnEdge)
char * dglStrerror(dglGraph_s *pgraph)
void dglFreeSPReport(dglGraph_s *pgraph, dglSPReport_s *pSPReport)
int G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
int dglFlatten(dglGraph_s *pGraph)
void Vect_graph_build(GRAPH *graph)
Build network graph.