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
Different MST algorithms produce same total weight
✅
3
Bellman-Ford = Dijkstra (non-negative)
bellman_ford_equals_dijkstra_test()
Algorithms agree on non-negative weighted graphs
✅
Pathfinding Correctness
#
Property
Test Function
Rationale
Status
4
Dijkstra path validity
dijkstra_path_validity_test()
Path starts/ends correctly, edges exist, weight accurate
✅
5
No-path detection
dijkstra_no_path_confirmed_by_bfs_test()
Dijkstra None confirmed by BFS unreachability
✅
6
Undirected path symmetry
undirected_path_symmetry_test()
Path weight A→B equals B→A in undirected graphs
✅
7
Triangle inequality
triangle_inequality_test()
Direct path ≤ path via intermediate node
✅
Complex Invariants
#
Property
Test Function
Rationale
Status
8
SCC components partition graph
scc_partition_test()
Components are disjoint and cover all nodes
✅
9
MST is spanning tree
mst_spanning_tree_test()
MST reaches all nodes in connected graph
✅
10
Bridge removal disconnects graph
bridge_removal_test()
Removing bridge increases connected components
✅
11
Degree centrality correctness
degree_centrality_correctness_test()
Normalized degree values match expectations
✅
12
Betweenness centrality non-negative
betweenness_centrality_non_negative_test()
All betweenness scores ≥ 0
✅
13
Closeness centrality range
closeness_centrality_in_valid_range_test()
All closeness scores in [0, 1]
✅
Testing Strategy
Hybrid Approach
Two complementary strategies are used:
Property-Based Testing (PBT)
Random graph generation via qcheck
~100 test cases per property
Graph sizes: 0-15 nodes, 0-30 edges
Best for: Structural properties, transformations
Example-Based Testing
Specific graph configurations
Deterministic, fast execution
Best for: Complex algorithms, performance-sensitive operations
Graph Generators
graph_generator()// Random directed/undirectedundirected_graph_generator()// Random undirecteddirected_graph_generator()// Random directedgraph_generator_custom(kind,n,e)// Custom size
Dependencies
[dev-dependencies]
qcheck = ">= 1.0.0 and < 2.0.0"