Change GraphTopologyConversion::convert return value to include the new GraphIsomorphism

This allows to convert maps for the converted graph.
This commit is contained in:
2026-10-12 21:33:49 +02:00
parent 1979d33649
commit b124e58b38
9 changed files with 228 additions and 79 deletions
+29
View File
@@ -94,6 +94,35 @@ impl<E: Copy, T: Clone> ElementMap<E, T> {
to_index: self.to_index,
}
}
/// Creates a new `ElementMap` indexed by elements of type `F`, such that for each element *e*
/// of this map that `mapping` maps to some *f*, the new map contains at *f* a clone of the
/// value this map contains at *e*.
///
/// A slot of `mapping` counts as unmapped if it holds the default value of `mapping`, which
/// must therefore never be a valid element of `F`. Unmapped slots are skipped. Slots of the new
/// map that no element is mapped to, and slots of this map beyond the length of `mapping` or
/// vice versa, are left at this map's default value. The `template` is only used to determine
/// the length and the index conversion function of the new map.
///
/// Iterates the raw slots of both maps, so it neither needs the graph nor the element handles.
pub(crate) fn remap<F: Copy + Eq>(
&self,
mapping: &ElementMap<E, F>,
template: &ElementMap<F, ()>,
) -> ElementMap<F, T> {
let mut result = ElementMap {
data: vec![self.default.clone(); template.data.len()],
default: self.default.clone(),
to_index: template.to_index,
};
for (value, &f) in self.data.iter().zip(&mapping.data) {
if f != mapping.default {
result.data[(template.to_index)(f)] = value.clone();
}
}
result
}
}
impl<E: Copy, T: Clone> Index<E> for ElementMap<E, T> {