use super::shared::{incident_degree, is_edge_in_input, symbolic_adjacency};
#[kani::proof]
#[kani::unwind(7)]
fn verify_build_adjacency_length() {
let (node_count, _edges, adjacency) = symbolic_adjacency();
assert_eq!(adjacency.len(), node_count);
}
#[kani::proof]
#[kani::unwind(7)]
fn verify_build_adjacency_preserves_edges() {
let (node_count, edges, adjacency) = symbolic_adjacency();
kani::assume(node_count > 0);
for edge in &edges {
let forward_found = adjacency[edge.left]
.iter()
.any(|&(neighbour, weight)| neighbour == edge.right && weight == edge.weight);
assert!(forward_found);
let reverse_found = adjacency[edge.right]
.iter()
.any(|&(neighbour, weight)| neighbour == edge.left && weight == edge.weight);
assert!(reverse_found);
}
}
#[kani::proof]
#[kani::unwind(7)]
fn verify_build_adjacency_indices_in_bounds() {
let (node_count, _edges, adjacency) = symbolic_adjacency();
for bucket in &adjacency {
for &(neighbour, _weight) in bucket {
assert!(neighbour < node_count);
}
}
}
#[kani::proof]
#[kani::unwind(7)]
fn verify_build_adjacency_symmetry() {
let (node_count, _edges, adjacency) = symbolic_adjacency();
kani::assume(node_count > 0);
for (node, bucket) in adjacency.iter().enumerate() {
for &(neighbour, weight) in bucket {
let mirror_found =
adjacency[neighbour]
.iter()
.any(|&(mirror_neighbour, mirror_weight)| {
mirror_neighbour == node && mirror_weight == weight
});
assert!(mirror_found);
}
}
}
#[kani::proof]
#[kani::unwind(7)]
fn verify_build_adjacency_no_spurious_edges() {
let (node_count, edges, adjacency) = symbolic_adjacency();
kani::assume(node_count > 0);
for (node, bucket) in adjacency.iter().enumerate() {
assert_eq!(bucket.len(), incident_degree(&edges, node));
for &(neighbour, weight) in bucket {
assert!(is_edge_in_input(&edges, node, neighbour, weight));
}
}
}
#[kani::proof]
#[kani::unwind(7)]
fn verify_build_adjacency_sorted_neighbours() {
let (_node_count, _edges, adjacency) = symbolic_adjacency();
for bucket in &adjacency {
for window in bucket.windows(2) {
assert!(window[0].0 <= window[1].0);
}
}
}