# Package presentation

cppRouting is an R package which provide functions to calculate distances, shortest paths and isochrones/isodistances on non-negative weighted graphs. For now, cppRouting can implement :

All these functions are written in C++ and use std::priority_queue container from the Standard Template Library.
This package have been made with Rcpp and parallel packages.

# Main functions

cppRouting package provide these functions :

• get_distance_matrix : compute distance matrix (between all combinations origin-destination nodes - one-to-many),
• get_distance_pair : compute distances between origin and destination by pair (one-to-one),
• get_path_pair : compute shortest paths between origin and destination by pair (one-to-one),
• get_multi_paths : compute shortest paths between all origin nodes and all destination nodes (one-to-many),
• get_isochrone : compute isochrones/isodistances with one or multiple breaks.
• cpp_simplify : remove non-intersection nodes, duplicated edges and isolated loops in the graph. Graph topology is preserved so distance calculation is faster and remains true. This function can be applied to very large graphs (several millions of nodes).
• get_detour : return nodes that are reachable within a fixed additional cost around shortest paths. This function can be useful in producing accessibility indicators.

### Path algorithms

The choice between all the algorithms is available for one-to-one calculation like get_distance_pair and get_path_pair.
In these functions, uni-directional Dijkstra algorithm is stopped when the destination node is reached.
A* and NBA* are relevant if geographic coordinates of all nodes are provided. Note that coordinates should be expressed in a projection system.
To be accurate and efficient, A* and NBA* algorithms should use an admissible heuristic function (here the Euclidean distance), e.g cost and heuristic function must be expressed in the same unit.
In cppRouting, heuristic function h for a node (n) is defined such that :
h(n,d) = ED(n,d) / k with h the heuristic, ED the Euclidean distance, d the destination node and 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. By default, constant is 1 and is designed for graphs with cost expressed in the same unit than coordinates (for example in meters).

If coordinates cannot be provided, bi-directional Dijkstra algorithm can offer a good alternative to A* in terms of performance.

# New algorithms cppRouting will provide in the future

• Contraction hierarchies implementation