Refactor ElementMap, removing its copy-on-write feature

This commit is contained in:
2026-10-11 22:24:00 +02:00
parent 4e20c49486
commit 3d7dda6f7b
9 changed files with 281 additions and 113 deletions
+3 -3
View File
@@ -7,7 +7,7 @@ This crate provides data structures to model graphs and to perform algorithms on
Currently supported are:
* Undirected graph types `Graph`, `AppendGraph`, and `FrozenGraph`, built on a flat, index-based adjacency list,
* Maps to freely associate custom data with vertices and edges,
* `ElementMap` to freely associate custom data with vertices and edges,
* Connectivity and pathing algorithms: Dijkstra's algorithm, DFS, and BFS in different variants,
* Exposed traits to implement custom graph data structures or algorithms.
@@ -22,14 +22,14 @@ use grapherity::models::Graph;
use grapherity::algorithms;
let mut graph = Graph::new();
// Creates a map for edge weights with a default weight.
let mut weights = graph.edge_map(1);
// Adds three vertices and two edges.
let v1 = graph.add_vertex();
let v2 = graph.add_vertex();
let v3 = graph.add_vertex();
graph.add_edge(v1, v2);
let e = graph.add_edge(v2, v3);
// Creates a map for edge weights with a default weight, after creating the edge.
let mut weights = graph.edge_map(1);
// Sets a non-default weight for the second edge.
weights[e] = 5;