You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: readme.Rmd
+18-12Lines changed: 18 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -46,13 +46,13 @@ Data has to be a 3 columns data.frame or matrix containing from, to and a cost/d
46
46
47
47
The choice between Dijkstra and A* algorithm is available for `get_distance_pair` and `get_path_pair`. In these functions, Dijkstra algorithm is stopped when the destination node is reached.
48
48
A* is relevant if geographic coordinates of all nodes are provided. Note that coordinates should be expressed in a projection system.
49
-
To be accurate and efficient, `A*` algorithm should use an admissible heuristic function (see https://en.wikipedia.org/wiki/A*_search_algorithm), e.g the cost and geographic coordinates must be expressed in the same unit.
49
+
To be accurate and efficient, `A*` algorithm should use an admissible heuristic function (here the Euclidean distance), e.g cost and heuristic function must be expressed in the same unit.
50
50
In `cppRouting`, heuristic function `h` is defined such that : h(xi,yi,xdestination,ydestination)/k, with a constant k; so in the case where coordinates are expressed in meters and cost is expressed in time, k is the maximum speed allowed on the road.
51
51
52
52
By default, constant is 1 and is designed for graphs with cost expressed in the same unit than coordinates (e.g meters).
53
53
54
-
55
-
###Let's see the benefit of the A* algorithm with the french road network :
Copy file name to clipboardExpand all lines: readme.md
+49-31Lines changed: 49 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,12 +45,15 @@ Main functions
45
45
46
46
The choice between Dijkstra and A\* algorithm is available for `get_distance_pair` and `get_path_pair`. In these functions, Dijkstra algorithm is stopped when the destination node is reached.
47
47
A\* is relevant if geographic coordinates of all nodes are provided. Note that coordinates should be expressed in a projection system.
48
-
To be accurate and efficient, `A*` algorithm should use an admissible heuristic function (see <https://en.wikipedia.org/wiki/A*_search_algorithm>), e.g the cost and geographic coordinates must be expressed in the same unit.
48
+
To be accurate and efficient, `A*` algorithm should use an admissible heuristic function (here the Euclidean distance), e.g cost and heuristic function must be expressed in the same unit.
49
49
In `cppRouting`, heuristic function `h` is defined such that : h(xi,yi,xdestination,ydestination)/k, with a constant k; so in the case where coordinates are expressed in meters and cost is expressed in time, k is the maximum speed allowed on the road.
50
50
51
51
By default, constant is 1 and is designed for graphs with cost expressed in the same unit than coordinates (e.g meters).
52
52
53
-
### Let's see the benefit of the A\* algorithm with the french road network :
53
+
Examples
54
+
--------
55
+
56
+
### Prepare data
54
57
55
58
```r
56
59
library(cppRouting)
@@ -82,7 +85,7 @@ head(roads)
82
85
## 5 4 113129 4.9680000
83
86
## 6 5 4 1.6680000
84
87
85
-
### Head of coordinates data
88
+
####Head of coordinates data
86
89
87
90
```r
88
91
head(coord)
@@ -103,7 +106,9 @@ head(coord)
103
106
graph<-makegraph(roads,directed=T,coords=coord)
104
107
```
105
108
106
-
### Run Dijkstra algorithm for finding minimum cost between pairs of nodes
109
+
### Distances by pairs between nodes
110
+
111
+
#### Using Dijkstra algorithm
107
112
108
113
```r
109
114
#Generate 2000 random origin and destination nodes
0 commit comments