Release 0.2.4 #7
+12
-12
@@ -1,17 +1,19 @@
|
||||
//! [`AppendGraph`], an undirected graph topology supporting addition only.
|
||||
|
||||
use crate::maps::{EdgeMap, VertexMap};
|
||||
use crate::traits::{GraphTopology, IncidenceCursor};
|
||||
|
||||
/// An opaque handle identifying a vertex in an [`AppendGraph`].
|
||||
///
|
||||
/// Handles are stable for the lifetime of the graph. They can be obtained via graph methods like
|
||||
/// [`GraphTopology::add_vertex`] and [`GraphTopology::vertices`].
|
||||
/// Handles are stable for the lifetime of the graph. Obtain via graph methods like
|
||||
/// [`AppendGraph::add_vertex`] and [`AppendGraph::vertices`].
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
||||
pub struct Vertex(usize);
|
||||
|
||||
/// An opaque handle identifying an edge in an [`AppendGraph`].
|
||||
///
|
||||
/// Handles are stable for the lifetime of the graph. They can be obtained via graph methods like
|
||||
/// [`GraphTopology::add_edge`] and [`GraphTopology::edges`].
|
||||
/// Handles are stable for the lifetime of the graph. Obtain via graph methods like
|
||||
/// [`AppendGraph::add_edge`] and [`AppendGraph::edges`].
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
||||
pub struct Edge(usize);
|
||||
|
||||
@@ -41,8 +43,7 @@ struct IncidenceEntry {
|
||||
|
||||
/// A resumable cursor over the incidences of a single vertex in an [`AppendGraph`].
|
||||
///
|
||||
/// Can be obtained via [`GraphTopology::incidence_cursor`]. See [`IncidenceCursor`] on how to use
|
||||
/// it.
|
||||
/// Obtain via [`AppendGraph::incidence_cursor`]. See [`IncidenceCursor`] on usage guidance.
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct AppendGraphIncidenceCursor {
|
||||
incidence: Option<Edge>,
|
||||
@@ -57,12 +58,11 @@ impl IncidenceCursor<AppendGraph> for AppendGraphIncidenceCursor {
|
||||
/// An undirected graph that supports adding vertices and edges, but not deleting them.
|
||||
///
|
||||
/// `AppendGraph` is optimised for workloads that incrementally build a graph and query it
|
||||
/// repeatedly. [`Vertex`]
|
||||
/// and [`Edge`] handles are never invalidated. Use [`Graph`] instead if you need to remove vertices
|
||||
/// or edges.
|
||||
/// repeatedly. [`Vertex`] and [`Edge`] handles are never invalidated. Use [`Graph`] instead if you
|
||||
/// need to remove vertices or edges.
|
||||
///
|
||||
/// Incidences are stored as interlaced adjacency lists in a single flat [`Vec`]. This means that
|
||||
/// vertex neighborhood traversals in general result in scattered index jumps.
|
||||
/// Incidences are stored as interleaved adjacency lists in a single flat [`Vec`]. In general,
|
||||
/// vertex neighborhood traversals result in scattered index jumps.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
@@ -77,7 +77,7 @@ impl IncidenceCursor<AppendGraph> for AppendGraphIncidenceCursor {
|
||||
/// assert!(graph.are_adjacent(v1, v2));
|
||||
/// ```
|
||||
///
|
||||
/// # Time and space complexity
|
||||
/// # Time and space complexity
|
||||
///
|
||||
/// Both [`add_vertex`] and [`add_edge`] run in amortised *O(1)* time. [`degree`] runs in *O(1)*
|
||||
/// time since vertex degrees are stored. Space complexity is *O(|V| + |E|)*.
|
||||
|
||||
Reference in New Issue
Block a user