Skip to main content

DagGraph

Struct DagGraph 

Source
pub struct DagGraph<E> { /* private fields */ }
Expand description

Directed acyclic graph generic over any E: Edge.

Rejects self-references and any edge whose insertion would create a cycle in the active-edge subgraph. Wraps an EdgeStore<E> to inherit archive / unarchive semantics for soft-delete cascades.

Deserialize runs the DAG invariants against the active subset of loaded edges; a corrupted file with a cycle or self-reference fails to load up front rather than silently rehydrating into an invariant-violating state.

The graph machinery is fully generic: external code can instantiate DagGraph<MyEdge> for any MyEdge: Edge without needing to modify this crate. The kanban-domain DependencyGraph uses three concrete instantiations (DagGraph<SpawnsEdge> / DagGraph<BlocksEdge> / etc.) but the machinery itself is open for extension.

Implementations§

Source§

impl<E: Edge> DagGraph<E>

Source

pub fn new() -> Self

Source

pub fn edges(&self) -> &[E]

Borrow the raw underlying edge list (active + archived). Persistence layers use this to serialise; size and membership queries go through the EdgeSet trait surface.

Source

pub fn add_edge_with_metadata(&mut self, edge: E) -> Result<(), GraphError>

Push an edge while preserving caller-supplied metadata.

Runs the same self-reference, duplicate, and cycle invariants as the trait’s Graph::add_edge:

  • self-references are rejected always;
  • active duplicates (an existing active source -> target) are rejected always; the duplicate check ignores archived edges so re-adding after archive succeeds;
  • cycles are rejected when the edge is active, ignored when it is archived (archived edges are not part of the active DAG and don’t constrain new mutations).

Load paths use this to rehydrate stored edges and surface corrupt-DAG state as a hard load failure.

Source

pub fn descendants(&self, node: E::NodeId) -> Vec<E::NodeId>

Transitive successors of node (descendants).

Source

pub fn ancestors(&self, node: E::NodeId) -> Vec<E::NodeId>

Transitive predecessors of node (ancestors).

Trait Implementations§

Source§

impl<E: Edge> Cascadable for DagGraph<E>

Source§

fn archive_node(&mut self, node: E::NodeId)

Archive every edge involving node (soft delete).
Source§

fn unarchive_node(&mut self, node: E::NodeId)

Unarchive every edge involving node.
Source§

fn remove_node(&mut self, node: E::NodeId)

Remove every edge involving node (hard delete).
Source§

impl<E: Clone> Clone for DagGraph<E>

Source§

fn clone(&self) -> DagGraph<E>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<E: Debug> Debug for DagGraph<E>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<E> Default for DagGraph<E>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de, E> Deserialize<'de> for DagGraph<E>
where E: Edge + Clone + Deserialize<'de>,

Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<E: Edge> Directed for DagGraph<E>

Source§

fn outgoing(&self, node: E::NodeId) -> Vec<E::NodeId>

Source§

fn incoming(&self, node: E::NodeId) -> Vec<E::NodeId>

Source§

impl<E: Edge> EdgeSet for DagGraph<E>

Source§

fn contains(&self, a: E::NodeId, b: E::NodeId) -> bool

Directed active-only membership: source-to-target ordering matters. Aligned with Graph::contains_edge.

Source§

fn contains_archived(&self, a: E::NodeId, b: E::NodeId) -> bool

Directed any-state membership including archived edges.

Source§

fn len(&self) -> usize

Total edge count (active + archived).
Source§

fn active_len(&self) -> usize

Active edge count only.
Source§

fn is_empty(&self) -> bool

True iff this set has no active edges. Archived edges, if any, are not counted: a graph whose entire active set has been archived reports is_empty() == true, matching what callers asking “anything here right now?” expect.
Source§

impl<E: Edge> Graph for DagGraph<E>

Source§

type NodeId = <E as Edge>::NodeId

Source§

fn add_edge(&mut self, from: E::NodeId, to: E::NodeId) -> Result<(), GraphError>

Add an edge from -> to. Returns GraphError::Cycle / GraphError::SelfReference when the implementation rejects.
Source§

fn remove_edge( &mut self, from: E::NodeId, to: E::NodeId, ) -> Result<(), GraphError>

Remove the edge from -> to. Returns GraphError::EdgeNotFound if no such edge exists.
Source§

fn contains_edge(&self, from: E::NodeId, to: E::NodeId) -> bool

True iff an edge from -> to is present.
Source§

impl<E: PartialEq> PartialEq for DagGraph<E>

Source§

fn eq(&self, other: &DagGraph<E>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<E> Serialize for DagGraph<E>
where E: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<E> StructuralPartialEq for DagGraph<E>

Auto Trait Implementations§

§

impl<E> Freeze for DagGraph<E>

§

impl<E> RefUnwindSafe for DagGraph<E>
where E: RefUnwindSafe,

§

impl<E> Send for DagGraph<E>
where E: Send,

§

impl<E> Sync for DagGraph<E>
where E: Sync,

§

impl<E> Unpin for DagGraph<E>
where E: Unpin,

§

impl<E> UnsafeUnpin for DagGraph<E>

§

impl<E> UnwindSafe for DagGraph<E>
where E: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.