11 Commits

Author SHA1 Message Date
warrence ad9850800d Update IncidenceCursor trait doc with note on Copy 2026-07-17 11:30:45 +02:00
warrence a14202effc Merge branch 'main' into release-0.3.0 2026-07-17 11:29:41 +02:00
warrence 5fa415841e Merge pull request 'Documentation updates' (#6) from release-0.2.3 into main
Reviewed-on: #6
2026-07-17 11:16:49 +02:00
warrence e8568a084a Fix doc example for early doc release 2026-07-17 11:15:12 +02:00
warrence e6b08d9148 Remove doc warnings for early doc release 2026-07-17 11:13:31 +02:00
warrence b62c263b08 Update package version 2026-07-17 11:12:21 +02:00
warrence 913a9e0baa Fix AppendGraph::capacity to actually use the underlying vec's capacity 2026-07-17 09:54:16 +02:00
warrence 8c6c98859c Add Copy to IncidenceCursor trait 2026-07-17 09:53:05 +02:00
warrence 24c08438d6 Add IncidenceCursor to prelude 2026-07-17 09:52:35 +02:00
warrence bf6a7142f3 Fix readme typo 2026-07-17 09:50:43 +02:00
warrence fb9dfe8280 Renamed len() to capacity() in EntityMap, VertexMap, and EdgeMap
len() is generally expected to describe the number of elements in a collection,
but in this case elements beyond len() are accessible without restriction.
capacity() is a better name because it describes data storage size.
2026-07-10 11:58:45 +02:00
5 changed files with 8 additions and 17 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "grapherity" name = "grapherity"
version = "0.2.2" version = "0.2.3"
authors = ["Stefan Müller"] authors = ["Stefan Müller"]
edition = "2024" edition = "2024"
rust-version = "1.85.0" rust-version = "1.85.0"
+1 -3
View File
@@ -127,15 +127,13 @@
//! [`GraphTopology::Vertex`]: crate::traits::GraphTopology::Vertex //! [`GraphTopology::Vertex`]: crate::traits::GraphTopology::Vertex
//! [`GraphTopologyDeletion`]: crate::traits::GraphTopologyDeletion //! [`GraphTopologyDeletion`]: crate::traits::GraphTopologyDeletion
#![warn(missing_docs)]
pub mod algorithms; pub mod algorithms;
pub mod maps; pub mod maps;
pub mod models; pub mod models;
pub mod traits; pub mod traits;
pub mod prelude { pub mod prelude {
pub use crate::traits::{GraphTopology, GraphTopologyDeletion}; pub use crate::traits::{GraphTopology, GraphTopologyDeletion, IncidenceCursor};
} }
mod testing; mod testing;
-10
View File
@@ -18,11 +18,6 @@ impl<V: Copy, T: Clone> VertexMap<V, T> {
self.inner.capacity() self.inner.capacity()
} }
#[deprecated(since = "0.2.2", note = "use 'capacity' instead")]
pub fn len(&self) -> usize {
self.capacity()
}
pub fn sync<G: GraphTopology<Vertex = V>>(&mut self, graph: &G) { pub fn sync<G: GraphTopology<Vertex = V>>(&mut self, graph: &G) {
self.inner.resize(graph.vertex_capacity()); self.inner.resize(graph.vertex_capacity());
} }
@@ -58,11 +53,6 @@ impl<E: Copy, T: Clone> EdgeMap<E, T> {
self.inner.capacity() self.inner.capacity()
} }
#[deprecated(since = "0.2.2", note = "use 'capacity' instead")]
pub fn len(&self) -> usize {
self.capacity()
}
pub fn sync<G: GraphTopology<Edge = E>>(&mut self, graph: &G) { pub fn sync<G: GraphTopology<Edge = E>>(&mut self, graph: &G) {
self.inner.resize(graph.edge_capacity()); self.inner.resize(graph.edge_capacity());
} }
+1 -1
View File
@@ -91,7 +91,7 @@ impl GraphTopology for AppendGraph {
} }
fn vertex_capacity(&self) -> usize { fn vertex_capacity(&self) -> usize {
self.vertices.len() self.vertices.capacity()
} }
fn vertex_map<T: Clone>(&self, default: T) -> VertexMap<Self::Vertex, T> { fn vertex_map<T: Clone>(&self, default: T) -> VertexMap<Self::Vertex, T> {
+5 -2
View File
@@ -38,7 +38,7 @@ pub trait GraphTopology {
/// when an algorithm needs to pause traversal, perform other graph queries or mutations, and /// when an algorithm needs to pause traversal, perform other graph queries or mutations, and
/// then continue from where it left off. This cursor type can be obtained via /// then continue from where it left off. This cursor type can be obtained via
/// [`incidence_cursor`](Self::incidence_cursor). /// [`incidence_cursor`](Self::incidence_cursor).
type IncidenceCursor: IncidenceCursor<Self> + Copy; type IncidenceCursor: IncidenceCursor<Self>;
/// Returns the number of vertices in the graph. /// Returns the number of vertices in the graph.
fn vertex_count(&self) -> usize; fn vertex_count(&self) -> usize;
@@ -210,10 +210,13 @@ pub trait GraphTopologyDeletion: GraphTopology {
/// A cursor for traversing the incidences of a vertex one step at a time. /// A cursor for traversing the incidences of a vertex one step at a time.
/// ///
/// Because the cursor is [`Copy`], its state can be saved and restored to replay or branch a
/// traversal.
///
/// Cursors are obtained via [`GraphTopology::incidence_cursor`]. See /// Cursors are obtained via [`GraphTopology::incidence_cursor`]. See
/// [`GraphTopology::IncidenceCursor`] for guidance on when to prefer a cursor over /// [`GraphTopology::IncidenceCursor`] for guidance on when to prefer a cursor over
/// [`GraphTopology::incidences`]. /// [`GraphTopology::incidences`].
pub trait IncidenceCursor<G: GraphTopology + ?Sized> { pub trait IncidenceCursor<G: GraphTopology + ?Sized>: Copy {
/// Advances the cursor and returns the next incidence as `Some((u, e))`, or `None` if the /// Advances the cursor and returns the next incidence as `Some((u, e))`, or `None` if the
/// traversal is exhausted. /// traversal is exhausted.
/// ///