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>
impl<E> EdgeStore<E>
Sourcepub fn retain<F: FnMut(&E) -> bool>(&mut self, f: F)
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.
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
Total edge count (active + archived).
Source§impl<E: Edge> EdgeStore<E>
impl<E: Edge> EdgeStore<E>
Sourcepub fn remove_node(&mut self, node_id: E::NodeId)
pub fn remove_node(&mut self, node_id: E::NodeId)
Remove every edge involving node (hard-delete cascade).
Sourcepub fn archive_node(&mut self, node_id: E::NodeId)
pub fn archive_node(&mut self, node_id: E::NodeId)
Archive every edge involving node (soft-delete cascade).
Sourcepub fn unarchive_node(&mut self, node_id: E::NodeId)
pub fn unarchive_node(&mut self, node_id: E::NodeId)
Unarchive every edge involving node.
Sourcepub fn remove_directed_edge(
&mut self,
source: E::NodeId,
target: E::NodeId,
) -> bool
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.
Sourcepub fn remove_undirected_edge(&mut self, a: E::NodeId, b: E::NodeId) -> bool
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.
Sourcepub fn outgoing(&self, node_id: E::NodeId) -> impl Iterator<Item = &E>
pub fn outgoing(&self, node_id: E::NodeId) -> impl Iterator<Item = &E>
Iterate every outgoing edge from node (source == node).
Sourcepub fn incoming(&self, node_id: E::NodeId) -> impl Iterator<Item = &E>
pub fn incoming(&self, node_id: E::NodeId) -> impl Iterator<Item = &E>
Iterate every incoming edge to node (target == node).
Sourcepub fn outgoing_active(&self, node_id: E::NodeId) -> impl Iterator<Item = &E>
pub fn outgoing_active(&self, node_id: E::NodeId) -> impl Iterator<Item = &E>
Iterate active outgoing edges from node.
Sourcepub fn incoming_active(&self, node_id: E::NodeId) -> impl Iterator<Item = &E>
pub fn incoming_active(&self, node_id: E::NodeId) -> impl Iterator<Item = &E>
Iterate active incoming edges to node.
Sourcepub fn active_edges(&self) -> impl Iterator<Item = &E>
pub fn active_edges(&self) -> impl Iterator<Item = &E>
Iterate every active edge.
Sourcepub fn adjacency_list(&self) -> HashMap<E::NodeId, Vec<E::NodeId>>
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.
Sourcepub fn active_edge_count(&self) -> usize
pub fn active_edge_count(&self) -> usize
Active-edge count.
Sourcepub fn would_create_cycle(&self, source: E::NodeId, target: E::NodeId) -> bool
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?
Sourcepub fn reachable_from(&self, start: E::NodeId) -> HashSet<E::NodeId>
pub fn reachable_from(&self, start: E::NodeId) -> HashSet<E::NodeId>
Set of nodes reachable from start via the active directed
adjacency.