Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ad9850800d | |||
| a14202effc | |||
| 913a9e0baa | |||
| 8c6c98859c | |||
| 24c08438d6 | |||
| bf6a7142f3 | |||
| fb9dfe8280 |
+1
-1
@@ -133,7 +133,7 @@ pub mod models;
|
||||
pub mod traits;
|
||||
|
||||
pub mod prelude {
|
||||
pub use crate::traits::{GraphTopology, GraphTopologyDeletion};
|
||||
pub use crate::traits::{GraphTopology, GraphTopologyDeletion, IncidenceCursor};
|
||||
}
|
||||
|
||||
mod testing;
|
||||
|
||||
-10
@@ -18,11 +18,6 @@ impl<V: Copy, T: Clone> VertexMap<V, T> {
|
||||
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) {
|
||||
self.inner.resize(graph.vertex_capacity());
|
||||
}
|
||||
@@ -58,11 +53,6 @@ impl<E: Copy, T: Clone> EdgeMap<E, T> {
|
||||
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) {
|
||||
self.inner.resize(graph.edge_capacity());
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ impl GraphTopology for AppendGraph {
|
||||
}
|
||||
|
||||
fn vertex_capacity(&self) -> usize {
|
||||
self.vertices.len()
|
||||
self.vertices.capacity()
|
||||
}
|
||||
|
||||
fn vertex_map<T: Clone>(&self, default: T) -> VertexMap<Self::Vertex, T> {
|
||||
|
||||
+5
-3
@@ -38,7 +38,7 @@ pub trait GraphTopology {
|
||||
/// 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
|
||||
/// [`incidence_cursor`](Self::incidence_cursor).
|
||||
type IncidenceCursor: IncidenceCursor<Self> + Copy;
|
||||
type IncidenceCursor: IncidenceCursor<Self>;
|
||||
|
||||
/// Returns the number of vertices in the graph.
|
||||
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.
|
||||
///
|
||||
/// 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
|
||||
/// [`GraphTopology::IncidenceCursor`] for guidance on when to prefer a cursor over
|
||||
/// [`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
|
||||
/// traversal is exhausted.
|
||||
///
|
||||
@@ -222,7 +225,6 @@ pub trait IncidenceCursor<G: GraphTopology + ?Sized> {
|
||||
/// ```
|
||||
/// # use grapherity::prelude::*;
|
||||
/// # use grapherity::models::Graph;
|
||||
/// # use grapherity::traits::IncidenceCursor;
|
||||
/// // Constructs a graph with two vertices connected to `v`.
|
||||
/// let mut graph = Graph::new();
|
||||
/// let v = graph.add_vertex();
|
||||
|
||||
Reference in New Issue
Block a user