From 5edcfb0d80955b974bc4837b386525075767cb0a Mon Sep 17 00:00:00 2001 From: Timo Betcke Date: Fri, 4 Oct 2024 11:26:59 +0100 Subject: [PATCH] Dealing with neighbours --- examples/mpi_complete_tree.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/examples/mpi_complete_tree.rs b/examples/mpi_complete_tree.rs index 78a0c23..3c727ab 100644 --- a/examples/mpi_complete_tree.rs +++ b/examples/mpi_complete_tree.rs @@ -36,19 +36,14 @@ pub fn main() { assert!(is_complete_linear_and_balanced(leaf_tree, &comm)); for &key in leaf_tree { - let mut parent = key; + // We only check interior keys. Leaf keys may not have a neighbor + // on the same level. + let mut parent = key.parent(); while parent.level() > 0 { // Check that the key itself is there. assert!(all_keys.contains_key(&key)); // Check that all its neighbours are there. for neighbor in parent.neighbours().iter().filter(|&key| key.is_valid()) { - if !all_keys.contains_key(neighbor) { - println!( - "Missing neighbor: {}. Key type {:#?}", - neighbor, - all_keys.get(&parent).unwrap() - ); - } assert!(all_keys.contains_key(neighbor)); } parent = parent.parent();