@@ -9,10 +9,44 @@ use dsi_progress_logger::no_logging;
99use webgraph:: graphs:: vec_graph:: VecGraph ;
1010use webgraph_algo:: distances:: exact_sum_sweep:: { self , Level } ;
1111
12- /// Directed graph with a cycle and a sink: 0→1→2→3→0, 2→4.
12+ /// Canonical test graph (8 nodes, 11 arcs).
13+ ///
14+ /// - Outdegree 0: node 7 (sink)
15+ /// - Outdegree 1: nodes 2, 3, 4, 6
16+ /// - Outdegree 2: nodes 0, 5
17+ /// - Outdegree 3: node 1
18+ /// - Indegree 0: node 0 (source)
19+ /// - Indegree 1: nodes 1, 3, 5, 7
20+ /// - Indegree 2: nodes 2, 4
21+ /// - Indegree 3: node 6
22+ /// - Cycle: 2 → 4 → 6 → 2
1323fn directed_graph ( ) -> ( VecGraph , VecGraph ) {
14- let graph = VecGraph :: from_arcs ( [ ( 0 , 1 ) , ( 1 , 2 ) , ( 2 , 3 ) , ( 3 , 0 ) , ( 2 , 4 ) ] ) ;
15- let transpose = VecGraph :: from_arcs ( [ ( 1 , 0 ) , ( 2 , 1 ) , ( 3 , 2 ) , ( 0 , 3 ) , ( 4 , 2 ) ] ) ;
24+ let graph = VecGraph :: from_arcs ( [
25+ ( 0 , 1 ) ,
26+ ( 0 , 2 ) ,
27+ ( 1 , 3 ) ,
28+ ( 1 , 4 ) ,
29+ ( 1 , 5 ) ,
30+ ( 2 , 4 ) ,
31+ ( 3 , 6 ) ,
32+ ( 4 , 6 ) ,
33+ ( 5 , 6 ) ,
34+ ( 5 , 7 ) ,
35+ ( 6 , 2 ) ,
36+ ] ) ;
37+ let transpose = VecGraph :: from_arcs ( [
38+ ( 1 , 0 ) ,
39+ ( 2 , 0 ) ,
40+ ( 3 , 1 ) ,
41+ ( 4 , 1 ) ,
42+ ( 5 , 1 ) ,
43+ ( 4 , 2 ) ,
44+ ( 6 , 3 ) ,
45+ ( 6 , 4 ) ,
46+ ( 6 , 5 ) ,
47+ ( 7 , 5 ) ,
48+ ( 2 , 6 ) ,
49+ ] ) ;
1650 ( graph, transpose)
1751}
1852
@@ -34,34 +68,37 @@ fn symm_graph() -> VecGraph {
3468fn test_ess_diameter_only ( ) -> Result < ( ) > {
3569 let ( graph, transpose) = directed_graph ( ) ;
3670 let result = exact_sum_sweep:: Diameter :: run ( & graph, & transpose, None , no_logging ! [ ] ) ;
37- assert_eq ! ( result. diameter, 4 ) ;
71+ assert_eq ! ( result. diameter, 3 ) ;
3872 Ok ( ( ) )
3973}
4074
4175#[ test]
4276fn test_ess_radius_only ( ) -> Result < ( ) > {
4377 let ( graph, transpose) = directed_graph ( ) ;
4478 let result = exact_sum_sweep:: Radius :: run ( & graph, & transpose, None , no_logging ! [ ] ) ;
45- assert_eq ! ( result. radius, 3 ) ;
79+ assert_eq ! ( result. radius, 2 ) ;
4680 Ok ( ( ) )
4781}
4882
4983#[ test]
5084fn test_ess_all_forward ( ) -> Result < ( ) > {
5185 let ( graph, transpose) = directed_graph ( ) ;
5286 let result = exact_sum_sweep:: AllForward :: run ( & graph, & transpose, None , no_logging ! [ ] ) ;
53- assert_eq ! ( result. diameter, 4 ) ;
54- assert_eq ! ( result. radius, 3 ) ;
55- assert_eq ! ( result. forward_eccentricities. as_ref( ) , & [ 3 , 3 , 3 , 4 , 0 ] ) ;
87+ assert_eq ! ( result. diameter, 3 ) ;
88+ assert_eq ! ( result. radius, 2 ) ;
89+ assert_eq ! (
90+ result. forward_eccentricities. as_ref( ) ,
91+ & [ 3 , 3 , 2 , 3 , 2 , 3 , 2 , 0 ]
92+ ) ;
5693 Ok ( ( ) )
5794}
5895
5996#[ test]
6097fn test_ess_radius_diameter ( ) -> Result < ( ) > {
6198 let ( graph, transpose) = directed_graph ( ) ;
6299 let result = exact_sum_sweep:: RadiusDiameter :: run ( & graph, & transpose, None , no_logging ! [ ] ) ;
63- assert_eq ! ( result. diameter, 4 ) ;
64- assert_eq ! ( result. radius, 3 ) ;
100+ assert_eq ! ( result. diameter, 3 ) ;
101+ assert_eq ! ( result. radius, 2 ) ;
65102 Ok ( ( ) )
66103}
67104
0 commit comments