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
+5 -10
View File
@@ -6,8 +6,8 @@ use typed_generational_arena::{Arena, Index};
use crate::maps::ElementMap;
use crate::models;
use crate::traits::{
GraphTopology, GraphTopologyAddition, GraphTopologyConversion, GraphTopologyDeletion,
Incidence, IncidenceCursor,
GraphIsomorphism, GraphTopology, GraphTopologyAddition, GraphTopologyConversion,
GraphTopologyDeletion, Incidence, IncidenceCursor,
};
/// An opaque handle identifying a vertex in a [`Graph`].
@@ -399,19 +399,14 @@ impl GraphTopologyDeletion for Graph {
}
impl GraphTopologyConversion for Graph {
fn convert<H: GraphTopology>(
source: &H,
) -> (
Self,
ElementMap<H::Vertex, Vertex>,
ElementMap<H::Edge, Edge>,
) {
fn convert<G: GraphTopology>(source: &G) -> (Self, GraphIsomorphism<G, Self>) {
let mut edge_map = source.edge_map(Edge::new(usize::MAX, usize::MAX));
let (result, vertex_map) =
models::convert_to_addition(source, Vertex::new(usize::MAX, usize::MAX), |e, new_e| {
edge_map[e] = new_e
});
(result, vertex_map, edge_map)
let iso = GraphIsomorphism::new(&result, vertex_map, edge_map);
(result, iso)
}
}