Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8f9f0bf4c8 |
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "grapherity"
|
name = "grapherity"
|
||||||
version = "0.2.3"
|
version = "0.2.2"
|
||||||
authors = ["Stefan Müller"]
|
authors = ["Stefan Müller"]
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
rust-version = "1.85.0"
|
rust-version = "1.85.0"
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ For more information, see the [documentation](https://docs.rs/grapherity/latest/
|
|||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
```
|
```rust
|
||||||
// Brings commonly used traits into scope.
|
// Brings commonly used traits into scope.
|
||||||
use grapherity::prelude::*;
|
use grapherity::prelude::*;
|
||||||
use grapherity::models::Graph;
|
use grapherity::models::Graph;
|
||||||
|
|||||||
+3
-1
@@ -127,13 +127,15 @@
|
|||||||
//! [`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, IncidenceCursor};
|
pub use crate::traits::{GraphTopology, GraphTopologyDeletion};
|
||||||
}
|
}
|
||||||
|
|
||||||
mod testing;
|
mod testing;
|
||||||
|
|||||||
+10
@@ -18,6 +18,11 @@ 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());
|
||||||
}
|
}
|
||||||
@@ -53,6 +58,11 @@ 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());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ impl GraphTopology for AppendGraph {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn vertex_capacity(&self) -> usize {
|
fn vertex_capacity(&self) -> usize {
|
||||||
self.vertices.capacity()
|
self.vertices.len()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn vertex_map<T: Clone>(&self, default: T) -> VertexMap<Self::Vertex, T> {
|
fn vertex_map<T: Clone>(&self, default: T) -> VertexMap<Self::Vertex, T> {
|
||||||
|
|||||||
+2
-5
@@ -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>;
|
type IncidenceCursor: IncidenceCursor<Self> + Copy;
|
||||||
|
|
||||||
/// 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,13 +210,10 @@ 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>: Copy {
|
pub trait IncidenceCursor<G: GraphTopology + ?Sized> {
|
||||||
/// 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.
|
||||||
///
|
///
|
||||||
|
|||||||
Reference in New Issue
Block a user