Vlib/graph.c File Reference

#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
#include <grass/dbmi.h>
#include <grass/Vect.h>

Include dependency graph for Vlib/graph.c:

Go to the source code of this file.

Functions

void Vect_graph_init (GRAPH *graph, int nodes_costs)
 Build network graph. Internal format for edge costs is integer, costs are multiplied before conversion to int by 1000. Costs -1 for infinity i.e. arc or node is closed and cannot be traversed.
void Vect_graph_build (GRAPH *graph)
void Vect_graph_add_edge (GRAPH *graph, int from, int to, double costs, int id)
 Add edge to graph. Internal format for edge costs is integer, costs are multiplied before conversion to int by 1000. Costs -1 for infinity i.e. arc or node is closed and cannot be traversed.
void Vect_graph_set_node_costs (GRAPH *graph, int node, double costs)
 Set node costs Internal format for edge costs is integer, costs are multiplied before conversion to int by 1000. Costs -1 for infinity i.e. arc or node is closed and cannot be traversed.
int Vect_graph_shortest_path (GRAPH *graph, int from, int to, struct ilist *List, double *cost)
 Find shortest path. Costs for 'from' and 'to' nodes are not considered (SP found even if 'from' or 'to' are 'closed' (costs = -1) and costs of these nodes are not added to SP costs result.


Function Documentation

Vect_graph_add_edge ( GRAPH *  graph,
int  from,
int  to,
double  costs,
int  id 
)

Add edge to graph. Internal format for edge costs is integer, costs are multiplied before conversion to int by 1000. Costs -1 for infinity i.e. arc or node is closed and cannot be traversed.

Parameters:
GRAPH *graph
from from node
to to node
costs 
id edge id

Definition at line 111 of file Vlib/graph.c.

References dglAddEdge().

void Vect_graph_build ( GRAPH *  graph  ) 

Definition at line 89 of file Vlib/graph.c.

References dglFlatten().

Vect_graph_init ( GRAPH *  graph,
int  nodes_costs 
)

Build network graph. Internal format for edge costs is integer, costs are multiplied before conversion to int by 1000. Costs -1 for infinity i.e. arc or node is closed and cannot be traversed.

Parameters:
GRAPH *graph
nodes_costs use node costs

Definition at line 68 of file Vlib/graph.c.

References dglInitialize().

Vect_graph_set_node_costs ( GRAPH *  graph,
int  node,
double  costs 
)

Set node costs Internal format for edge costs is integer, costs are multiplied before conversion to int by 1000. Costs -1 for infinity i.e. arc or node is closed and cannot be traversed.

Parameters:
GRAPH *graph
node 
costs 

Definition at line 134 of file Vlib/graph.c.

References dglGetNode(), and dglNodeSet_Attr().

int Vect_graph_shortest_path ( GRAPH *  graph,
int  from,
int  to,
struct ilist *  List,
double *  cost 
)

Find shortest path. Costs for 'from' and 'to' nodes are not considered (SP found even if 'from' or 'to' are 'closed' (costs = -1) and costs of these nodes are not added to SP costs result.

Returns:
number of segments : ( 0 is correct for from = to, or List == NULL ), ? sum of costs is better return value, -1 : destination unreachable
Parameters:
graph 
from 
to 
List 
cost 

Definition at line 160 of file Vlib/graph.c.

References _dglSPReport::cArc, dglEdgeGet_Cost(), dglEdgeGet_Id(), dglFreeSPReport(), dglShortestDistance(), dglShortestPath(), dglStrerror(), _dglSPReport::nDistance, _dglSPArc::nDistance, _dglSPArc::nFrom, _dglSPArc::nTo, _dglSPReport::pArc, _dglSPArc::pnEdge, Vect_list_append(), and Vect_reset_list().


Generated on Sun Apr 6 17:32:48 2008 for GRASS by  doxygen 1.5.5