pub struct StablePayloadGraph<NodePayload, EdgePayload> { /* private fields */ }Expand description
A mutable directed payload graph with generation-checked stable keys.
Implementations§
Source§impl<NodePayload, EdgePayload> StablePayloadGraph<NodePayload, EdgePayload>
impl<NodePayload, EdgePayload> StablePayloadGraph<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 payload and returns a key that detects later slot reuse.
§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 a directed edge between two live stable node keys.
§Errors
Returns an error for stale endpoints or exhausted stable 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 outgoing_edges( &self, node: StableNodeKey, ) -> impl Iterator<Item = StableEdgeKey> + '_
pub fn incoming_edges( &self, node: StableNodeKey, ) -> impl Iterator<Item = StableEdgeKey> + '_
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> StablePayloadGraph<NodePayload, EdgePayload>
impl<NodePayload, EdgePayload> StablePayloadGraph<NodePayload, EdgePayload>
Sourcepub fn freeze(self) -> Result<FrozenPayloadGraph<NodePayload, EdgePayload>>
pub fn freeze(self) -> Result<FrozenPayloadGraph<NodePayload, EdgePayload>>
Compacts live slots into an immutable CSR-backed payload graph.
§Errors
Returns an error if compact index capacity is exhausted.
Source§impl<NodePayload, EdgePayload> StablePayloadGraph<NodePayload, EdgePayload>
impl<NodePayload, EdgePayload> StablePayloadGraph<NodePayload, EdgePayload>
pub fn map_payloads<MappedNode, MappedEdge, NodeMap, EdgeMap>( self, map_node: NodeMap, map_edge: EdgeMap, ) -> StablePayloadGraph<MappedNode, MappedEdge>
Source§impl<NodePayload, EdgePayload> StablePayloadGraph<NodePayload, EdgePayload>
impl<NodePayload, EdgePayload> StablePayloadGraph<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 a live edge without changing its stable key or payload.
§Errors
Returns an error when either new endpoint key is stale.
Trait Implementations§
Source§impl<NodePayload: Clone, EdgePayload: Clone> Clone for StablePayloadGraph<NodePayload, EdgePayload>
impl<NodePayload: Clone, EdgePayload: Clone> Clone for StablePayloadGraph<NodePayload, EdgePayload>
Source§fn clone(&self) -> StablePayloadGraph<NodePayload, EdgePayload>
fn clone(&self) -> StablePayloadGraph<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 StablePayloadGraph<NodePayload, EdgePayload>
impl<NodePayload: Debug, EdgePayload: Debug> Debug for StablePayloadGraph<NodePayload, EdgePayload>
Source§impl<NodePayload, EdgePayload> Default for StablePayloadGraph<NodePayload, EdgePayload>
impl<NodePayload, EdgePayload> Default for StablePayloadGraph<NodePayload, EdgePayload>
Source§impl<NodePayload, EdgePayload> GraphView for StablePayloadGraph<NodePayload, EdgePayload>
impl<NodePayload, EdgePayload> GraphView for StablePayloadGraph<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 outgoing_edges( &self, node: Self::Node, ) -> impl Iterator<Item = Self::Edge> + '_
fn incoming_edges( &self, node: Self::Node, ) -> impl Iterator<Item = Self::Edge> + '_
fn edge_references( &self, ) -> impl Iterator<Item = (Self::Edge, EdgeEndpoints<Self::Node>)> + '_
Auto Trait Implementations§
impl<NodePayload, EdgePayload> Freeze for StablePayloadGraph<NodePayload, EdgePayload>
impl<NodePayload, EdgePayload> RefUnwindSafe for StablePayloadGraph<NodePayload, EdgePayload>where
NodePayload: RefUnwindSafe,
EdgePayload: RefUnwindSafe,
impl<NodePayload, EdgePayload> Send for StablePayloadGraph<NodePayload, EdgePayload>
impl<NodePayload, EdgePayload> Sync for StablePayloadGraph<NodePayload, EdgePayload>
impl<NodePayload, EdgePayload> Unpin for StablePayloadGraph<NodePayload, EdgePayload>
impl<NodePayload, EdgePayload> UnsafeUnpin for StablePayloadGraph<NodePayload, EdgePayload>
impl<NodePayload, EdgePayload> UnwindSafe for StablePayloadGraph<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