Skip to main content

EdgeStore

Struct EdgeStore 

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

Generic edge-list container over any E: Edge.

Stores edges as a flat list for efficient serialization. Exposes only kind-agnostic operations: anything that depends on direction or per-kind matching semantics (e.g. “is this an undirected edge between a and b in either order?”) lives on the sub-graph type that wraps EdgeStore.

E: Edge lets node-level cascade ops (archive_node, unarchive_node, remove_node) and traversal queries (outgoing, incoming, adjacency_list) work without knowing E’s concrete metadata. The graph machinery is reusable across any kanban-domain or external kind that satisfies the trait.

Implementations§

Source§

impl<E> EdgeStore<E>

Source

pub fn new() -> Self

Create an empty edge store.

Source

pub fn retain<F: FnMut(&E) -> bool>(&mut self, f: F)

Retain only edges matching f. The kind-aware remove_directed_edge / remove_undirected_edge helpers below build on this; sub-graphs that need other matching semantics can call retain directly.

Source

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

Borrow every edge (active + archived).

Source

pub fn edge_count(&self) -> usize

Total edge count (active + archived).

Source§

impl<E: Edge> EdgeStore<E>

Source

pub fn remove_node(&mut self, node_id: E::NodeId)

Remove every edge involving node (hard-delete cascade).

Source

pub fn archive_node(&mut self, node_id: E::NodeId)

Archive every edge involving node (soft-delete cascade).

Source

pub fn unarchive_node(&mut self, node_id: E::NodeId)

Unarchive every edge involving node.

Source

pub fn remove_directed_edge( &mut self, source: E::NodeId, target: E::NodeId, ) -> bool

Remove the single active edge whose source == source and target == target exactly (directed-graph semantics). Archived edges with the same endpoints are preserved — they’re history, not part of the current view, and a remove of the current edge must not silently destroy the history record. Returns true iff an active edge was removed.

Source

pub fn remove_undirected_edge(&mut self, a: E::NodeId, b: E::NodeId) -> bool

Remove any active edge whose endpoints are {a, b} regardless of ordering (undirected-graph semantics). Archived edges are preserved. Returns true iff at least one active edge was removed.

Source

pub fn outgoing(&self, node_id: E::NodeId) -> impl Iterator<Item = &E>

Iterate every outgoing edge from node (source == node).

Source

pub fn incoming(&self, node_id: E::NodeId) -> impl Iterator<Item = &E>

Iterate every incoming edge to node (target == node).

Source

pub fn outgoing_active(&self, node_id: E::NodeId) -> impl Iterator<Item = &E>

Iterate active outgoing edges from node.

Source

pub fn incoming_active(&self, node_id: E::NodeId) -> impl Iterator<Item = &E>

Iterate active incoming edges to node.

Source

pub fn active_edges(&self) -> impl Iterator<Item = &E>

Iterate every active edge.

Source

pub fn adjacency_list(&self) -> HashMap<E::NodeId, Vec<E::NodeId>>

Active-edge directed adjacency list: source -> [target]. Sub-graphs that need a different view (e.g. undirected neighbours) build their own from active_edges.

Source

pub fn active_edge_count(&self) -> usize

Active-edge count.

Source

pub fn would_create_cycle(&self, source: E::NodeId, target: E::NodeId) -> bool

Would adding source -> target create a cycle in the active directed adjacency?

Source

pub fn has_cycle(&self) -> bool

Does the active directed adjacency contain any cycle?

Source

pub fn reachable_from(&self, start: E::NodeId) -> HashSet<E::NodeId>

Set of nodes reachable from start via the active directed adjacency.

Trait Implementations§

Source§

impl<E: Clone> Clone for EdgeStore<E>

Source§

fn clone(&self) -> EdgeStore<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 EdgeStore<E>

Source§

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

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

impl<E> Default for EdgeStore<E>

Source§

fn default() -> Self

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

impl<'de, E> Deserialize<'de> for EdgeStore<E>
where E: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

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

impl<E: PartialEq> PartialEq for EdgeStore<E>

Source§

fn eq(&self, other: &EdgeStore<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 EdgeStore<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 EdgeStore<E>

Auto Trait Implementations§

§

impl<E> Freeze for EdgeStore<E>

§

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

§

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

§

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

§

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

§

impl<E> UnsafeUnpin for EdgeStore<E>

§

impl<E> UnwindSafe for EdgeStore<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.