@@ -35,16 +35,20 @@ SEXP dijkstra_R(SEXP n_R, SEXP source_ind_R, SEXP arcs_R)
3535
3636 std::vector<double > min_distance;
3737 std::vector<int > path_list;
38+ sp::comptime_t algo_runtime;
3839
39- sp::dijkstra::compute_paths (as<int >(source_ind_R), arc_list, min_distance, path_list);
40+ sp::dijkstra::compute_paths (as<int >(source_ind_R), arc_list, min_distance, path_list, &algo_runtime );
4041
4142 //
4243
4344 for (int i=0 ; i < path_list.size (); i++) {
4445 path_list[i]++;
4546 }
4647
47- return Rcpp::List::create (Rcpp::Named (" min_dist" ) = min_distance,Rcpp::Named (" path_list" ) = path_list);
48+ double runtime_out = algo_runtime.count ();
49+
50+ return Rcpp::List::create (Rcpp::Named (" min_dist" ) = min_distance,Rcpp::Named (" path_list" ) = path_list,
51+ Rcpp::Named (" elapsed_time" ) = runtime_out);
4852 } catch ( std::exception &ex ) {
4953 forward_exception_to_r ( ex );
5054 } catch (...) {
@@ -65,11 +69,15 @@ SEXP dijkstra_simp_R(SEXP n_R, SEXP source_ind_R, SEXP dest_ind_R, SEXP arcs_R)
6569
6670 std::vector<double > min_distance;
6771 std::vector<int > path_list;
72+ sp::comptime_t algo_runtime;
6873
69- sp::dijkstra::compute_path (as<int >(source_ind_R), dest_ind, arc_list, min_distance, path_list);
74+ sp::dijkstra::compute_path (as<int >(source_ind_R), dest_ind, arc_list, min_distance, path_list, &algo_runtime );
7075 std::list<int > opt_path = sp::get_shortest_path (dest_ind, path_list);
7176
72- return Rcpp::List::create (Rcpp::Named (" min_dist" ) = min_distance[dest_ind],Rcpp::Named (" path_list" ) = opt_path);
77+ double runtime_out = algo_runtime.count ();
78+
79+ return Rcpp::List::create (Rcpp::Named (" min_dist" ) = min_distance[dest_ind],Rcpp::Named (" path_list" ) = opt_path,
80+ Rcpp::Named (" elapsed_time" ) = runtime_out);
7381 } catch ( std::exception &ex ) {
7482 forward_exception_to_r ( ex );
7583 } catch (...) {
0 commit comments