@@ -27,6 +27,7 @@ pub use crate::fast_graph::FastGraph;
2727pub use crate :: fast_graph32:: FastGraph32 ;
2828pub use crate :: fast_graph_builder:: FastGraphBuilder ;
2929pub use crate :: fast_graph_builder:: Params ;
30+ use crate :: fast_graph_builder:: ParamsWithOrder ;
3031pub use crate :: input_graph:: Edge ;
3132pub use crate :: input_graph:: InputGraph ;
3233pub use crate :: path_calculator:: PathCalculator ;
@@ -67,6 +68,15 @@ pub fn prepare_with_order(input_graph: &InputGraph, order: &[NodeId]) -> Result<
6768 FastGraphBuilder :: build_with_order ( input_graph, order)
6869}
6970
71+ /// Like `prepare_with_order()`, but allows specifying some parameters used for the graph preparation
72+ pub fn prepare_with_order_with_params (
73+ input_graph : & InputGraph ,
74+ order : & [ NodeId ] ,
75+ params : & ParamsWithOrder ,
76+ ) -> Result < FastGraph , String > {
77+ FastGraphBuilder :: build_with_order_with_params ( input_graph, order, params)
78+ }
79+
7080/// Calculates the shortest path from `source` to `target`.
7181pub fn calc_path ( fast_graph : & FastGraph , source : NodeId , target : NodeId ) -> Option < ShortestPath > {
7282 let mut calc = PathCalculator :: new ( fast_graph. get_num_nodes ( ) ) ;
@@ -136,6 +146,7 @@ mod tests {
136146 use crate :: preparation_graph:: PreparationGraph ;
137147
138148 use super :: * ;
149+ use crate :: fast_graph_builder:: ParamsWithOrder ;
139150
140151 #[ test]
141152 fn routing_on_random_graph ( ) {
@@ -391,9 +402,11 @@ mod tests {
391402 fn run_performance_test_dist ( ) {
392403 println ! ( "Running performance test for Bremen dist" ) ;
393404 // road network extracted from OSM data from Bremen, Germany using the road distance as weight
405+ // prep: 190ms, query: 16μs, out: 68494, in: 68426
406+ // todo: try to tune parameters
394407 run_performance_test (
395408 & InputGraph :: from_file ( "meta/test_maps/bremen_dist.gr" ) ,
396- & Params :: default ( ) ,
409+ & Params :: new ( 0.1 , 500 , 2 , 50 ) ,
397410 845493338 ,
398411 30265 ,
399412 )
@@ -404,9 +417,11 @@ mod tests {
404417 fn run_performance_test_time ( ) {
405418 println ! ( "Running performance test for Bremen time" ) ;
406419 // road network extracted from OSM data from Bremen, Germany using the travel time as weight
420+ // prep: 256ms, query: 11μs, out: 64825, in: 65027
421+ // todo: try to tune parameters
407422 run_performance_test (
408423 & InputGraph :: from_file ( "meta/test_maps/bremen_time.gr" ) ,
409- & Params :: default ( ) ,
424+ & Params :: new ( 0.1 , 100 , 2 , 100 ) ,
410425 88104267255 ,
411426 30265 ,
412427 ) ;
@@ -416,9 +431,11 @@ mod tests {
416431 #[ test]
417432 fn run_performance_test_ballard ( ) {
418433 println ! ( "Running performance test for ballard" ) ;
434+ // prep: 1150ms, query: 53μs, out: 43849, in: 43700
435+ // todo: try to tune parameters
419436 run_performance_test (
420437 & InputGraph :: from_file ( "meta/test_maps/graph_ballard.gr" ) ,
421- & Params :: new ( 0.01 ) ,
438+ & Params :: new ( 0.1 , 100 , 3 , 100 ) ,
422439 28409159409 ,
423440 14992 ,
424441 ) ;
@@ -428,9 +445,11 @@ mod tests {
428445 #[ test]
429446 fn run_performance_test_23rd ( ) {
430447 println ! ( "Running performance test for 23rd" ) ;
448+ // prep: 170ms, query: 23μs, out: 11478, in: 11236
449+ // todo: try to tune parameters
431450 run_performance_test (
432451 & InputGraph :: from_file ( "meta/test_maps/graph_23rd.gr" ) ,
433- & Params :: default ( ) ,
452+ & Params :: new ( 0.1 , 100 , 3 , 100 ) ,
434453 19438403873 ,
435454 20421 ,
436455 ) ;
@@ -440,26 +459,46 @@ mod tests {
440459 #[ test]
441460 fn run_performance_test_south_seattle_car ( ) {
442461 println ! ( "Running performance test for South Seattle car" ) ;
462+ // prep: 877ms, query: 26μs, out: 68777, in: 68161
463+ // todo: try to tune parameters
443464 run_performance_test (
444465 & InputGraph :: from_file ( "meta/test_maps/south_seattle_car.gr" ) ,
445- & Params :: default ( ) ,
466+ & Params :: new ( 0.1 , 100 , 10 , 100 ) ,
446467 77479396 ,
447468 30805 ,
448469 ) ;
449470 }
450471
451472 #[ ignore]
452473 #[ test]
453- fn run_performance_test_dist_fixed_ordering ( ) {
474+ fn run_performance_test_bremen_dist_fixed_ordering ( ) {
454475 println ! ( "Running performance test for Bremen dist (fixed node ordering)" ) ;
476+ // prep: 340ms, prep_order: 64ms, query: 16μs, out: 66646, in: 66725
477+ // todo: try to tune parameters
455478 run_performance_test_fixed_ordering (
456479 & InputGraph :: from_file ( "meta/test_maps/bremen_dist.gr" ) ,
457480 & Params :: default ( ) ,
481+ & ParamsWithOrder :: default ( ) ,
458482 845493338 ,
459483 30265 ,
460484 ) ;
461485 }
462486
487+ #[ ignore]
488+ #[ test]
489+ fn run_performance_test_south_seattle_fixed_ordering ( ) {
490+ println ! ( "Running performance test for South Seattle car (fixed node ordering)" ) ;
491+ // prep: 811ms, prep order: 138ms, query: 27μs, out: 68777, in: 68161
492+ // todo: try to tune parameters
493+ run_performance_test_fixed_ordering (
494+ & InputGraph :: from_file ( "meta/test_maps/south_seattle_car.gr" ) ,
495+ & Params :: new ( 0.1 , 100 , 10 , 100 ) ,
496+ & ParamsWithOrder :: new ( 100 ) ,
497+ 77479396 ,
498+ 30805 ,
499+ ) ;
500+ }
501+
463502 fn run_performance_test (
464503 input_graph : & InputGraph ,
465504 params : & Params ,
@@ -484,6 +523,7 @@ mod tests {
484523 fn run_performance_test_fixed_ordering (
485524 input_graph : & InputGraph ,
486525 params : & Params ,
526+ params_with_order : & ParamsWithOrder ,
487527 expected_checksum : usize ,
488528 expected_num_not_found : usize ,
489529 ) {
@@ -496,7 +536,10 @@ mod tests {
496536 ) ;
497537 let order = get_node_ordering ( & fast_graph) ;
498538 prepare_algo (
499- & mut |input_graph| fast_graph = prepare_with_order ( input_graph, & order) . unwrap ( ) ,
539+ & mut |input_graph| {
540+ fast_graph =
541+ prepare_with_order_with_params ( input_graph, & order, params_with_order) . unwrap ( )
542+ } ,
500543 & input_graph,
501544 ) ;
502545 print_fast_graph_stats ( & fast_graph) ;
0 commit comments