pub struct AcyclicPayloadGraph<NodePayload, EdgePayload> { /* private fields */ }Expand description
A stable mutable payload graph that rejects cycle-creating mutations.
Implementations§
Source§impl<NodePayload, EdgePayload> AcyclicPayloadGraph<NodePayload, EdgePayload>
impl<NodePayload, EdgePayload> AcyclicPayloadGraph<NodePayload, EdgePayload>
pub const fn new() -> Self
Sourcepub fn try_from_graph(
graph: StablePayloadGraph<NodePayload, EdgePayload>,
) -> Result<Self>
pub fn try_from_graph( graph: StablePayloadGraph<NodePayload, EdgePayload>, ) -> Result<Self>
Wraps an existing graph after validating the DAG invariant.
§Errors
Returns an error if the input contains a directed cycle.
Sourcepub fn add_node(&mut self, payload: NodePayload) -> Result<StableNodeKey>
pub fn add_node(&mut self, payload: NodePayload) -> Result<StableNodeKey>
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 an edge only when the graph remains acyclic.
§Errors
Returns an error for stale endpoints, exhausted capacity, or a cycle.
Sourcepub fn set_edge_endpoints(
&mut self,
edge: StableEdgeKey,
source: StableNodeKey,
target: StableNodeKey,
) -> Result<bool>
pub fn set_edge_endpoints( &mut self, edge: StableEdgeKey, source: StableNodeKey, target: StableNodeKey, ) -> Result<bool>
Retargets an edge only when the graph remains acyclic.
§Errors
Returns an error for stale endpoints or a cycle.
pub fn remove_node(&mut self, key: StableNodeKey) -> Option<NodePayload>
pub fn remove_edge(&mut self, key: StableEdgeKey) -> Option<EdgePayload>
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 const fn graph(&self) -> &StablePayloadGraph<NodePayload, EdgePayload>
pub fn into_inner(self) -> StablePayloadGraph<NodePayload, EdgePayload>
Trait Implementations§
Source§impl<NodePayload: Clone, EdgePayload: Clone> Clone for AcyclicPayloadGraph<NodePayload, EdgePayload>
impl<NodePayload: Clone, EdgePayload: Clone> Clone for AcyclicPayloadGraph<NodePayload, EdgePayload>
Source§fn clone(&self) -> AcyclicPayloadGraph<NodePayload, EdgePayload>
fn clone(&self) -> AcyclicPayloadGraph<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 AcyclicPayloadGraph<NodePayload, EdgePayload>
impl<NodePayload: Debug, EdgePayload: Debug> Debug for AcyclicPayloadGraph<NodePayload, EdgePayload>
Source§impl<NodePayload: Default, EdgePayload: Default> Default for AcyclicPayloadGraph<NodePayload, EdgePayload>
impl<NodePayload: Default, EdgePayload: Default> Default for AcyclicPayloadGraph<NodePayload, EdgePayload>
Source§fn default() -> AcyclicPayloadGraph<NodePayload, EdgePayload>
fn default() -> AcyclicPayloadGraph<NodePayload, EdgePayload>
Returns the “default value” for a type. Read more
Source§impl<NodePayload, EdgePayload> GraphView for AcyclicPayloadGraph<NodePayload, EdgePayload>
impl<NodePayload, EdgePayload> GraphView for AcyclicPayloadGraph<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 AcyclicPayloadGraph<NodePayload, EdgePayload>
impl<NodePayload, EdgePayload> RefUnwindSafe for AcyclicPayloadGraph<NodePayload, EdgePayload>where
NodePayload: RefUnwindSafe,
EdgePayload: RefUnwindSafe,
impl<NodePayload, EdgePayload> Send for AcyclicPayloadGraph<NodePayload, EdgePayload>
impl<NodePayload, EdgePayload> Sync for AcyclicPayloadGraph<NodePayload, EdgePayload>
impl<NodePayload, EdgePayload> Unpin for AcyclicPayloadGraph<NodePayload, EdgePayload>
impl<NodePayload, EdgePayload> UnsafeUnpin for AcyclicPayloadGraph<NodePayload, EdgePayload>
impl<NodePayload, EdgePayload> UnwindSafe for AcyclicPayloadGraph<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