[][src]Struct algorithms_edu::algo::graph::UnweightedAdjacencyList

pub struct UnweightedAdjacencyList { /* fields omitted */ }

An unweighted graph represented by an unweighted adjacency list. This is in principle the same as WeightedAdjacencyList, except that no weights are involved and thus a simple usize is able to represent an outgoing edge.

Implementations

impl UnweightedAdjacencyList[src]

pub fn bfs(&self, start: usize) -> BfsResult[src]

Perform a breadth first search on a graph a starting node start.

impl UnweightedAdjacencyList[src]

pub fn dfs_recursive(&self, start: usize) -> usize[src]

impl UnweightedAdjacencyList[src]

pub fn eulerian_path(&self) -> Result<Vec<usize>, EulerianPathError>[src]

Returns a list of edge_count + 1 node ids that give the Eulerian path or an EulerianPathError if no path exists or the graph is disconnected.

impl UnweightedAdjacencyList[src]

pub fn scc(&self) -> SccResult[src]

impl UnweightedAdjacencyList[src]

pub fn center(&self) -> Center[src]

Finds the center(s) of an undirected tree. The adjacency list must be build with undirected edges, and does not contain cycles, so that it qualifies the definition for a tree.

impl UnweightedAdjacencyList[src]

impl UnweightedAdjacencyList[src]

pub fn with_size(n: usize) -> Self[src]

Initialize an empty adjacency list that can hold up to n nodes.

pub fn is_empty(&self) -> bool[src]

pub fn add_directed_edge(&mut self, u: usize, v: usize)[src]

Add a directed edge from node u to node v

pub fn add_undirected_edge(&mut self, u: usize, v: usize)[src]

Add an undirected edge between nodes u and v.

pub fn new_directed(size: usize, edges: &[[usize; 2]]) -> Self[src]

pub fn new_undirected(size: usize, edges: &[[usize; 2]]) -> Self[src]

pub fn edges(&self) -> impl Iterator<Item = [usize; 2]> + '_[src]

Iterates over all edges in the gragh. Each item is an array of length 2, showing the source and destination of this edge.

pub fn edge_count(&self) -> usize[src]

Number of edges in the graph

pub fn nodes(&self) -> impl Iterator<Item = (usize, &Vec<usize>)>[src]

Iterates over all nodes in the graph. Each item is a tuple of the node id and a Vec of all its outgoing edges

pub fn node_count(&self) -> usize[src]

Number of nodes (vertices) in the graph

Trait Implementations

impl BfsReconstructPath for UnweightedAdjacencyList[src]

pub fn bfs<T: Queue<usize>>(&self, start: usize) -> Vec<Option<usize>>[src]

Perform a breadth first search on a graph a starting node start.

impl Debug for UnweightedAdjacencyList[src]

impl Index<usize> for UnweightedAdjacencyList[src]

Allows the outgoing edges of a node to be accessed easily.

type Output = Vec<usize>

The returned type after indexing.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,