Add Clone to graph models, and tests

This commit is contained in:
2026-09-19 17:19:47 +02:00
parent 4c6a8a43e4
commit e593298eba
6 changed files with 164 additions and 0 deletions
+8
View File
@@ -87,9 +87,16 @@ impl IncidenceCursor<FrozenGraph> for FrozenGraphIncidenceCursor {
///
/// [`degree`] runs in *O(1)* time. Space complexity is *O(|V| + |E|)*.
///
/// # Cloning
///
/// [`Vertex`] and [`Edge`] handles obtained from a clone are valid, and refer to the same vertex or
/// edge in the original, and vice versa. However, once cloned, the two instances no longer affect
/// each other.
///
/// [`degree`]: Self::degree
/// [`AppendGraph`]: crate::models::AppendGraph
/// [`Graph`]: crate::models::Graph
#[derive(Clone)]
pub struct FrozenGraph {
vertices: Vec<usize>,
incidences: Vec<IncidenceEntry>,
@@ -255,6 +262,7 @@ mod trait_tests {
use super::FrozenGraph;
crate::graph_topology_tests!(FrozenGraph);
crate::graph_topology_clone_tests!(FrozenGraph);
}
#[cfg(test)]