Renamed FromGraph to GraphTopologyConversion to align with existing traits and separate from From trait
This commit is contained in:
+19
-18
@@ -6,8 +6,8 @@ use typed_generational_arena::{Arena, Index};
|
||||
use crate::maps::ElementMap;
|
||||
use crate::models;
|
||||
use crate::traits::{
|
||||
FromGraph, GraphTopology, GraphTopologyAddition, GraphTopologyDeletion, Incidence,
|
||||
IncidenceCursor,
|
||||
GraphTopology, GraphTopologyAddition, GraphTopologyConversion, GraphTopologyDeletion,
|
||||
Incidence, IncidenceCursor,
|
||||
};
|
||||
|
||||
/// An opaque handle identifying a vertex in a [`Graph`].
|
||||
@@ -400,19 +400,8 @@ impl GraphTopologyDeletion for Graph {
|
||||
}
|
||||
}
|
||||
|
||||
impl<H: GraphTopology> From<&H> for Graph {
|
||||
fn from(source: &H) -> Self {
|
||||
models::build_from_topology::<Self, _>(
|
||||
source,
|
||||
Vertex::new(usize::MAX, usize::MAX),
|
||||
|_, _| {},
|
||||
)
|
||||
.0
|
||||
}
|
||||
}
|
||||
|
||||
impl FromGraph for Graph {
|
||||
fn from_graph<H: GraphTopology>(
|
||||
impl GraphTopologyConversion for Graph {
|
||||
fn convert<H: GraphTopology>(
|
||||
source: &H,
|
||||
) -> (
|
||||
Self,
|
||||
@@ -421,13 +410,24 @@ impl FromGraph for Graph {
|
||||
) {
|
||||
let mut edge_map = source.edge_map(Edge::new(usize::MAX, usize::MAX));
|
||||
let (result, vertex_map) =
|
||||
models::build_from_topology(source, Vertex::new(usize::MAX, usize::MAX), |e, new_e| {
|
||||
models::convert_to_addition(source, Vertex::new(usize::MAX, usize::MAX), |e, new_e| {
|
||||
edge_map[e] = new_e
|
||||
});
|
||||
(result, vertex_map, edge_map)
|
||||
}
|
||||
}
|
||||
|
||||
impl<H: GraphTopology> From<&H> for Graph {
|
||||
fn from(source: &H) -> Self {
|
||||
models::convert_to_addition::<Self, _>(
|
||||
source,
|
||||
Vertex::new(usize::MAX, usize::MAX),
|
||||
|_, _| {},
|
||||
)
|
||||
.0
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod trait_tests {
|
||||
use super::Graph;
|
||||
@@ -439,8 +439,9 @@ mod trait_tests {
|
||||
crate::graph_topology_addition_deletion_tests!(Graph);
|
||||
crate::graph_topology_clone_tests!(Graph);
|
||||
crate::graph_topology_addition_clone_tests!(Graph);
|
||||
crate::graph_topology_from_graph_tests!(Graph, AppendGraph);
|
||||
crate::graph_topology_addition_from_graph_tests!(Graph, AppendGraph);
|
||||
crate::graph_topology_conversion_tests!(Graph, AppendGraph);
|
||||
crate::graph_topology_addition_conversion_tests!(Graph, AppendGraph);
|
||||
crate::from_tests!(Graph, AppendGraph);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user