Renamed FromGraph to GraphTopologyConversion to align with existing traits and separate from From trait

This commit is contained in:
2026-09-29 23:16:57 +02:00
parent 9d43f0cb8d
commit c8855daddf
11 changed files with 125 additions and 98 deletions
+9 -9
View File
@@ -2,7 +2,7 @@ use std::fmt::Debug;
use crate::maps::ElementMap;
use crate::models::{AppendGraph, FrozenGraph};
use crate::traits::{FromGraph, GraphTopology, GraphTopologyAddition, Incidence};
use crate::traits::{GraphTopology, GraphTopologyAddition, GraphTopologyConversion, Incidence};
pub trait MakeTestGraph: GraphTopology + Sized {
fn standard() -> (
@@ -175,7 +175,7 @@ impl MakeTestGraph for FrozenGraph {
[Vec<Incidence<Self::Vertex, Self::Edge>>; 10],
) {
let (build, vertices, edges, incidences) = AppendGraph::standard();
let (graph, vertex_map, edge_map) = FrozenGraph::from_graph(&build);
let (graph, vertex_map, edge_map) = FrozenGraph::convert(&build);
(
graph,
vertices.map(|v| vertex_map[v]),
@@ -197,31 +197,31 @@ impl MakeTestGraph for FrozenGraph {
fn single_vertex() -> (Self, Self::Vertex) {
let (build, v) = AppendGraph::single_vertex();
let (graph, vertex_map, _) = FrozenGraph::from_graph(&build);
let (graph, vertex_map, _) = FrozenGraph::convert(&build);
(graph, vertex_map[v])
}
fn single_edge() -> (Self, [Self::Vertex; 2], Self::Edge) {
let (build, vertices, e) = AppendGraph::single_edge();
let (graph, vertex_map, edge_map) = FrozenGraph::from_graph(&build);
let (graph, vertex_map, edge_map) = FrozenGraph::convert(&build);
(graph, vertices.map(|v| vertex_map[v]), edge_map[e])
}
fn disconnected() -> (Self, [Self::Vertex; 3]) {
let (build, vertices) = AppendGraph::disconnected();
let (graph, vertex_map, _) = FrozenGraph::from_graph(&build);
let (graph, vertex_map, _) = FrozenGraph::convert(&build);
(graph, vertices.map(|v| vertex_map[v]))
}
fn loop_edge() -> (Self, Self::Vertex, Self::Edge) {
let (build, v, e) = AppendGraph::loop_edge();
let (graph, vertex_map, edge_map) = FrozenGraph::from_graph(&build);
let (graph, vertex_map, edge_map) = FrozenGraph::convert(&build);
(graph, vertex_map[v], edge_map[e])
}
fn multiple_edges<const K: usize>() -> (Self, [Self::Vertex; 2], [Self::Edge; K]) {
let (build, vertices, edges) = AppendGraph::multiple_edges();
let (graph, vertex_map, edge_map) = FrozenGraph::from_graph(&build);
let (graph, vertex_map, edge_map) = FrozenGraph::convert(&build);
(
graph,
vertices.map(|v| vertex_map[v]),
@@ -231,7 +231,7 @@ impl MakeTestGraph for FrozenGraph {
fn two_edge_path() -> (Self, [Self::Vertex; 3], [Self::Edge; 2]) {
let (build, vertices, edges) = AppendGraph::two_edge_path();
let (graph, vertex_map, edge_map) = FrozenGraph::from_graph(&build);
let (graph, vertex_map, edge_map) = FrozenGraph::convert(&build);
(
graph,
vertices.map(|v| vertex_map[v]),
@@ -241,7 +241,7 @@ impl MakeTestGraph for FrozenGraph {
fn two_edge_path_with_loops() -> (Self, [Self::Vertex; 3], [Self::Edge; 4]) {
let (build, vertices, edges) = AppendGraph::two_edge_path_with_loops();
let (graph, vertex_map, edge_map) = FrozenGraph::from_graph(&build);
let (graph, vertex_map, edge_map) = FrozenGraph::convert(&build);
(
graph,
vertices.map(|v| vertex_map[v]),