pub struct AdjGraph { /* private fields */ }Expand description
An adjacency-list directed graph.
Implementations§
Source§impl AdjGraph
impl AdjGraph
Sourcepub fn add_undirected(&mut self, u: usize, v: usize)
pub fn add_undirected(&mut self, u: usize, v: usize)
Add an undirected edge.
Sourcepub fn vertex_count(&self) -> usize
pub fn vertex_count(&self) -> usize
Number of vertices.
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
Number of (directed) edges.
Sourcepub fn bfs(&self, start: usize) -> Vec<usize>
pub fn bfs(&self, start: usize) -> Vec<usize>
BFS from start; returns visited vertices in BFS order.
Sourcepub fn dfs(&self, start: usize) -> Vec<usize>
pub fn dfs(&self, start: usize) -> Vec<usize>
DFS from start; returns visited vertices in DFS order.
Sourcepub fn shortest_path(&self, src: usize, dst: usize) -> Option<Vec<usize>>
pub fn shortest_path(&self, src: usize, dst: usize) -> Option<Vec<usize>>
BFS shortest path from src to dst (unweighted). Returns None if unreachable.
Sourcepub fn is_reachable(&self, src: usize, dst: usize) -> bool
pub fn is_reachable(&self, src: usize, dst: usize) -> bool
Check if dst is reachable from src via BFS.
Auto Trait Implementations§
impl Freeze for AdjGraph
impl RefUnwindSafe for AdjGraph
impl Send for AdjGraph
impl Sync for AdjGraph
impl Unpin for AdjGraph
impl UnsafeUnpin for AdjGraph
impl UnwindSafe for AdjGraph
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