pub struct AdjacencyList {
pub n: usize,
pub edges: Vec<Vec<usize>>,
}Expand description
Unweighted graph stored as an adjacency list. Directed by default.
Fields§
§n: usize§edges: Vec<Vec<usize>>Implementations§
Source§impl AdjacencyList
impl AdjacencyList
Sourcepub fn add_edge(&mut self, u: usize, v: usize) -> GraphalgResult<()>
pub fn add_edge(&mut self, u: usize, v: usize) -> GraphalgResult<()>
Add a directed edge u -> v. Returns error if endpoints are out of range.
Sourcepub fn add_undirected_edge(&mut self, u: usize, v: usize) -> GraphalgResult<()>
pub fn add_undirected_edge(&mut self, u: usize, v: usize) -> GraphalgResult<()>
Add an undirected edge (u, v).
Sourcepub fn neighbors(&self, u: usize) -> GraphalgResult<&[usize]>
pub fn neighbors(&self, u: usize) -> GraphalgResult<&[usize]>
Out-neighbors of vertex u.
Sourcepub fn in_degrees(&self) -> Vec<usize>
pub fn in_degrees(&self) -> Vec<usize>
Compute the in-degree of each vertex.
Sourcepub fn out_degrees(&self) -> Vec<usize>
pub fn out_degrees(&self) -> Vec<usize>
Compute the out-degree of each vertex.
Trait Implementations§
Source§impl Clone for AdjacencyList
impl Clone for AdjacencyList
Source§fn clone(&self) -> AdjacencyList
fn clone(&self) -> AdjacencyList
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for AdjacencyList
impl RefUnwindSafe for AdjacencyList
impl Send for AdjacencyList
impl Sync for AdjacencyList
impl Unpin for AdjacencyList
impl UnsafeUnpin for AdjacencyList
impl UnwindSafe for AdjacencyList
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