pub struct Graph<E> { /* private fields */ }Expand description
Generic graph structure that can hold any edge type E
Stores edges as an edge list for efficient serialization. Provides adjacency list views for graph algorithms.
Implementations§
Source§impl<E> Graph<E>
impl<E> Graph<E>
Sourcepub fn add_edge(&mut self, edge: Edge<E>) -> KanbanResult<()>
pub fn add_edge(&mut self, edge: Edge<E>) -> KanbanResult<()>
Add an edge to the graph
Note: Cycle checking must be done by caller if needed
(see would_create_cycle method)
Sourcepub fn remove_edge(&mut self, source: Uuid, target: Uuid) -> boolwhere
E: Clone,
pub fn remove_edge(&mut self, source: Uuid, target: Uuid) -> boolwhere
E: Clone,
Remove an edge between two nodes
Returns true if an edge was removed, false if no matching edge found
Sourcepub fn remove_node(&mut self, node_id: Uuid)
pub fn remove_node(&mut self, node_id: Uuid)
Remove all edges involving a node (for deletion cascades)
Sourcepub fn archive_node(&mut self, node_id: Uuid)
pub fn archive_node(&mut self, node_id: Uuid)
Archive all edges involving a node (for archive cascades)
Sourcepub fn unarchive_node(&mut self, node_id: Uuid)
pub fn unarchive_node(&mut self, node_id: Uuid)
Unarchive all edges involving a node (for unarchive cascades)
Sourcepub fn outgoing(&self, node_id: Uuid) -> Vec<&Edge<E>>
pub fn outgoing(&self, node_id: Uuid) -> Vec<&Edge<E>>
Get all outgoing edges from a node (where node is source)
Sourcepub fn incoming(&self, node_id: Uuid) -> Vec<&Edge<E>>
pub fn incoming(&self, node_id: Uuid) -> Vec<&Edge<E>>
Get all incoming edges to a node (where node is target)
Sourcepub fn outgoing_active(&self, node_id: Uuid) -> Vec<&Edge<E>>
pub fn outgoing_active(&self, node_id: Uuid) -> Vec<&Edge<E>>
Get all active outgoing edges from a node
Sourcepub fn incoming_active(&self, node_id: Uuid) -> Vec<&Edge<E>>
pub fn incoming_active(&self, node_id: Uuid) -> Vec<&Edge<E>>
Get all active incoming edges to a node
Sourcepub fn neighbors(&self, node_id: Uuid) -> Vec<Uuid>where
E: Clone,
pub fn neighbors(&self, node_id: Uuid) -> Vec<Uuid>where
E: Clone,
Get all neighbor node IDs (connected nodes, handling bidirectional edges)
Sourcepub fn neighbors_active(&self, node_id: Uuid) -> Vec<Uuid>where
E: Clone,
pub fn neighbors_active(&self, node_id: Uuid) -> Vec<Uuid>where
E: Clone,
Get all active neighbor node IDs
Sourcepub fn adjacency_list(&self) -> HashMap<Uuid, Vec<Uuid>>where
E: Clone,
pub fn adjacency_list(&self) -> HashMap<Uuid, Vec<Uuid>>where
E: Clone,
Build an adjacency list view of the graph (for algorithms) Only includes active edges
Sourcepub fn active_edges(&self) -> Vec<&Edge<E>>
pub fn active_edges(&self) -> Vec<&Edge<E>>
Get all active edges
Sourcepub fn has_edge(&self, source: Uuid, target: Uuid) -> boolwhere
E: Clone,
pub fn has_edge(&self, source: Uuid, target: Uuid) -> boolwhere
E: Clone,
Check if an edge exists between two nodes
Sourcepub fn would_create_cycle(&self, source: Uuid, target: Uuid) -> boolwhere
E: Clone,
pub fn would_create_cycle(&self, source: Uuid, target: Uuid) -> boolwhere
E: Clone,
Check if adding an edge would create a cycle Only checks active edges
Sourcepub fn has_cycle(&self) -> boolwhere
E: Clone,
pub fn has_cycle(&self) -> boolwhere
E: Clone,
Check if the graph contains any cycles Only checks active edges
Sourcepub fn reachable_from(&self, start: Uuid) -> HashSet<Uuid>where
E: Clone,
pub fn reachable_from(&self, start: Uuid) -> HashSet<Uuid>where
E: Clone,
Get all nodes reachable from a given node Only considers active edges
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
Get the count of edges (total, including archived)
Sourcepub fn active_edge_count(&self) -> usize
pub fn active_edge_count(&self) -> usize
Get the count of active edges