Add Clone to graph models, and tests
This commit is contained in:
@@ -49,6 +49,7 @@ impl IncidenceSlot {
|
||||
/// Referenced by [`Vertex`] as a type parameter of the underlying arena. Not intended for direct
|
||||
/// external use.
|
||||
#[doc(hidden)]
|
||||
#[derive(Clone)]
|
||||
pub struct VertexIncidenceHeader {
|
||||
incidence_count: usize,
|
||||
first_incidence: Option<IncidenceSlot>,
|
||||
@@ -129,12 +130,19 @@ impl IncidenceCursor<Graph> for GraphIncidenceCursor {
|
||||
/// planned, performing deletions first allows freed slots to be reused by subsequent additions,
|
||||
/// potentially avoiding reallocation.
|
||||
///
|
||||
/// # 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.
|
||||
///
|
||||
/// [`add_vertex`]: Self::add_vertex
|
||||
/// [`add_edge`]: Self::add_edge
|
||||
/// [`degree`]: Self::degree
|
||||
/// [`delete_vertex`]: Self::delete_vertex
|
||||
/// [`delete_edge`]: Self::delete_edge
|
||||
/// [`AppendGraph`]: crate::models::AppendGraph
|
||||
#[derive(Clone)]
|
||||
pub struct Graph {
|
||||
// TODO: Arena index and generation types could be externalized to Graph.
|
||||
vertices: Arena<VertexIncidenceHeader, usize, usize>,
|
||||
@@ -398,6 +406,8 @@ mod trait_tests {
|
||||
crate::graph_topology_addition_tests!(Graph);
|
||||
crate::graph_topology_deletion_tests!(Graph);
|
||||
crate::graph_topology_addition_deletion_tests!(Graph);
|
||||
crate::graph_topology_clone_tests!(Graph);
|
||||
crate::graph_topology_addition_clone_tests!(Graph);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user