pub struct KeyedPayloadGraph<Key, NodePayload, EdgePayload> { /* private fields */ }Expand description
A GraphMap-style key index backed by generation-stable graph handles.
Keys provide domain lookup while algorithms continue to use compact stable
handles from StablePayloadGraph.
Implementations§
Source§impl<Key, NodePayload, EdgePayload> KeyedPayloadGraph<Key, NodePayload, EdgePayload>
impl<Key, NodePayload, EdgePayload> KeyedPayloadGraph<Key, NodePayload, EdgePayload>
pub fn new() -> Self
pub fn with_capacity(nodes: usize, edges: usize) -> Self
Sourcepub fn insert_node(
&mut self,
key: Key,
payload: NodePayload,
) -> Result<(StableNodeKey, Option<NodePayload>)>
pub fn insert_node( &mut self, key: Key, payload: NodePayload, ) -> Result<(StableNodeKey, Option<NodePayload>)>
Inserts a key or replaces its node payload without changing its handle.
Returns the stable handle and the previous payload, when one existed.
§Errors
Returns an error when the stable node index space is exhausted.
pub fn node_key(&self, key: &Key) -> Option<StableNodeKey>
pub fn node(&self, key: &Key) -> Option<&NodePayload>
pub fn node_mut(&mut self, key: &Key) -> Option<&mut NodePayload>
Sourcepub fn add_edge(
&mut self,
source: &Key,
target: &Key,
payload: EdgePayload,
) -> Result<StableEdgeKey>
pub fn add_edge( &mut self, source: &Key, target: &Key, payload: EdgePayload, ) -> Result<StableEdgeKey>
Adds a directed edge between two existing domain keys.
§Errors
Returns an error for a missing endpoint or exhausted edge indices.
pub fn remove_node(&mut self, key: &Key) -> Option<NodePayload>
pub const fn graph(&self) -> &StablePayloadGraph<NodePayload, EdgePayload>
pub fn node_count(&self) -> usize
pub fn edge_count(&self) -> usize
pub fn into_parts( self, ) -> (StablePayloadGraph<NodePayload, EdgePayload>, impl Iterator<Item = (Key, StableNodeKey)>)
Trait Implementations§
Source§impl<Key: Clone, NodePayload: Clone, EdgePayload: Clone> Clone for KeyedPayloadGraph<Key, NodePayload, EdgePayload>
impl<Key: Clone, NodePayload: Clone, EdgePayload: Clone> Clone for KeyedPayloadGraph<Key, NodePayload, EdgePayload>
Source§fn clone(&self) -> KeyedPayloadGraph<Key, NodePayload, EdgePayload>
fn clone(&self) -> KeyedPayloadGraph<Key, 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 moreAuto Trait Implementations§
impl<Key, NodePayload, EdgePayload> Freeze for KeyedPayloadGraph<Key, NodePayload, EdgePayload>
impl<Key, NodePayload, EdgePayload> RefUnwindSafe for KeyedPayloadGraph<Key, NodePayload, EdgePayload>
impl<Key, NodePayload, EdgePayload> Send for KeyedPayloadGraph<Key, NodePayload, EdgePayload>
impl<Key, NodePayload, EdgePayload> Sync for KeyedPayloadGraph<Key, NodePayload, EdgePayload>
impl<Key, NodePayload, EdgePayload> Unpin for KeyedPayloadGraph<Key, NodePayload, EdgePayload>
impl<Key, NodePayload, EdgePayload> UnsafeUnpin for KeyedPayloadGraph<Key, NodePayload, EdgePayload>
impl<Key, NodePayload, EdgePayload> UnwindSafe for KeyedPayloadGraph<Key, NodePayload, EdgePayload>
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