pub struct StableUndirectedPayloadGraph<NodePayload, EdgePayload> { /* private fields */ }Expand description
A mutable undirected payload graph with generation-checked stable keys.
Implementations§
Source§impl<NodePayload, EdgePayload> StableUndirectedPayloadGraph<NodePayload, EdgePayload>
impl<NodePayload, EdgePayload> StableUndirectedPayloadGraph<NodePayload, EdgePayload>
pub const fn new() -> Self
pub fn with_capacity(nodes: usize, edges: usize) -> Self
Sourcepub fn add_node(&mut self, payload: NodePayload) -> Result<StableNodeKey>
pub fn add_node(&mut self, payload: NodePayload) -> Result<StableNodeKey>
Adds a node payload and returns a generation-stable key.
§Errors
Returns an error when the stable index space is exhausted.
Sourcepub fn add_edge(
&mut self,
source: StableNodeKey,
target: StableNodeKey,
payload: EdgePayload,
) -> Result<StableEdgeKey>
pub fn add_edge( &mut self, source: StableNodeKey, target: StableNodeKey, payload: EdgePayload, ) -> Result<StableEdgeKey>
Adds one undirected edge. A self-loop occupies one incidence entry.
§Errors
Returns an error for stale endpoints or exhausted edge indices.
pub fn node(&self, key: StableNodeKey) -> Option<&NodePayload>
pub fn node_mut(&mut self, key: StableNodeKey) -> Option<&mut NodePayload>
pub fn edge(&self, key: StableEdgeKey) -> Option<&EdgePayload>
pub fn edge_mut(&mut self, key: StableEdgeKey) -> Option<&mut EdgePayload>
pub fn edge_endpoints( &self, key: StableEdgeKey, ) -> Option<EdgeEndpoints<StableNodeKey>>
pub fn nodes(&self) -> impl Iterator<Item = (StableNodeKey, &NodePayload)>
pub fn edges(&self) -> impl Iterator<Item = (StableEdgeKey, &EdgePayload)>
pub fn incident_edges( &self, node: StableNodeKey, ) -> impl DoubleEndedIterator<Item = StableEdgeKey> + ExactSizeIterator + '_
pub const fn node_count(&self) -> usize
pub const fn edge_count(&self) -> usize
pub const fn is_empty(&self) -> bool
Source§impl<NodePayload, EdgePayload> StableUndirectedPayloadGraph<NodePayload, EdgePayload>
impl<NodePayload, EdgePayload> StableUndirectedPayloadGraph<NodePayload, EdgePayload>
Sourcepub fn freeze(
self,
) -> Result<FrozenUndirectedPayloadGraph<NodePayload, EdgePayload>>
pub fn freeze( self, ) -> Result<FrozenUndirectedPayloadGraph<NodePayload, EdgePayload>>
Compacts live stable slots into immutable undirected incidence CSR.
§Errors
Returns an error if compact index capacity is exhausted.
Source§impl<NodePayload, EdgePayload> StableUndirectedPayloadGraph<NodePayload, EdgePayload>
impl<NodePayload, EdgePayload> StableUndirectedPayloadGraph<NodePayload, EdgePayload>
pub fn remove_edge(&mut self, key: StableEdgeKey) -> Option<EdgePayload>
pub fn remove_node(&mut self, key: StableNodeKey) -> Option<NodePayload>
Sourcepub fn set_edge_endpoints(
&mut self,
key: StableEdgeKey,
source: StableNodeKey,
target: StableNodeKey,
) -> Result<bool>
pub fn set_edge_endpoints( &mut self, key: StableEdgeKey, source: StableNodeKey, target: StableNodeKey, ) -> Result<bool>
Moves an edge without changing its stable key or payload.
§Errors
Returns an error when either new endpoint is stale.
Trait Implementations§
Source§impl<NodePayload: Clone, EdgePayload: Clone> Clone for StableUndirectedPayloadGraph<NodePayload, EdgePayload>
impl<NodePayload: Clone, EdgePayload: Clone> Clone for StableUndirectedPayloadGraph<NodePayload, EdgePayload>
Source§fn clone(&self) -> StableUndirectedPayloadGraph<NodePayload, EdgePayload>
fn clone(&self) -> StableUndirectedPayloadGraph<NodePayload, EdgePayload>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<NodePayload: Debug, EdgePayload: Debug> Debug for StableUndirectedPayloadGraph<NodePayload, EdgePayload>
impl<NodePayload: Debug, EdgePayload: Debug> Debug for StableUndirectedPayloadGraph<NodePayload, EdgePayload>
Source§impl<NodePayload, EdgePayload> Default for StableUndirectedPayloadGraph<NodePayload, EdgePayload>
impl<NodePayload, EdgePayload> Default for StableUndirectedPayloadGraph<NodePayload, EdgePayload>
Source§impl<NodePayload, EdgePayload> IndexUndirectedGraphView for StableUndirectedPayloadGraph<NodePayload, EdgePayload>
impl<NodePayload, EdgePayload> IndexUndirectedGraphView for StableUndirectedPayloadGraph<NodePayload, EdgePayload>
Source§impl<NodePayload, EdgePayload> UndirectedGraphView for StableUndirectedPayloadGraph<NodePayload, EdgePayload>
impl<NodePayload, EdgePayload> UndirectedGraphView for StableUndirectedPayloadGraph<NodePayload, EdgePayload>
type Node = StableNodeKey
type Edge = StableEdgeKey
fn node_count(&self) -> usize
fn edge_count(&self) -> usize
fn contains_node(&self, node: Self::Node) -> bool
fn contains_edge(&self, edge: Self::Edge) -> bool
fn node_indices(&self) -> impl Iterator<Item = Self::Node> + '_
fn edge_indices(&self) -> impl Iterator<Item = Self::Edge> + '_
fn edge_endpoints(&self, edge: Self::Edge) -> Option<EdgeEndpoints<Self::Node>>
fn incident_edges( &self, node: Self::Node, ) -> impl DoubleEndedIterator<Item = Self::Edge> + ExactSizeIterator + '_
fn opposite(&self, edge: Self::Edge, node: Self::Node) -> Option<Self::Node>
Auto Trait Implementations§
impl<NodePayload, EdgePayload> Freeze for StableUndirectedPayloadGraph<NodePayload, EdgePayload>
impl<NodePayload, EdgePayload> RefUnwindSafe for StableUndirectedPayloadGraph<NodePayload, EdgePayload>where
NodePayload: RefUnwindSafe,
EdgePayload: RefUnwindSafe,
impl<NodePayload, EdgePayload> Send for StableUndirectedPayloadGraph<NodePayload, EdgePayload>
impl<NodePayload, EdgePayload> Sync for StableUndirectedPayloadGraph<NodePayload, EdgePayload>
impl<NodePayload, EdgePayload> Unpin for StableUndirectedPayloadGraph<NodePayload, EdgePayload>
impl<NodePayload, EdgePayload> UnsafeUnpin for StableUndirectedPayloadGraph<NodePayload, EdgePayload>
impl<NodePayload, EdgePayload> UnwindSafe for StableUndirectedPayloadGraph<NodePayload, EdgePayload>where
NodePayload: UnwindSafe,
EdgePayload: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more