pub struct UnweightedAdjacencyList { /* private fields */ }
Expand description
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§
Source§impl UnweightedAdjacencyList
impl UnweightedAdjacencyList
pub fn dfs_recursive(&self, start: usize) -> usize
Source§impl UnweightedAdjacencyList
impl UnweightedAdjacencyList
Sourcepub fn eulerian_path(&self) -> Result<Vec<usize>, EulerianPathError>
pub fn eulerian_path(&self) -> Result<Vec<usize>, EulerianPathError>
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.
Source§impl UnweightedAdjacencyList
impl UnweightedAdjacencyList
pub fn is_isomorphic_with(&self, other: &UnweightedAdjacencyList) -> bool
Source§impl UnweightedAdjacencyList
impl UnweightedAdjacencyList
Sourcepub fn with_size(n: usize) -> Self
pub fn with_size(n: usize) -> Self
Initialize an empty adjacency list that can hold up to n nodes.
pub fn is_empty(&self) -> bool
Sourcepub fn add_directed_edge(&mut self, u: usize, v: usize)
pub fn add_directed_edge(&mut self, u: usize, v: usize)
Add a directed edge from node u
to node v
Sourcepub fn add_undirected_edge(&mut self, u: usize, v: usize)
pub fn add_undirected_edge(&mut self, u: usize, v: usize)
Add an undirected edge between nodes u
and v
.
pub fn new_directed(size: usize, edges: &[[usize; 2]]) -> Self
pub fn new_undirected(size: usize, edges: &[[usize; 2]]) -> Self
Sourcepub fn edges(&self) -> impl Iterator<Item = [usize; 2]> + '_
pub fn edges(&self) -> impl Iterator<Item = [usize; 2]> + '_
Iterates over all edges in the gragh. Each item is an array of length 2, showing the source and destination of this edge.
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
Number of edges in the graph
Sourcepub fn nodes(&self) -> impl Iterator<Item = (usize, &Vec<usize>)>
pub fn nodes(&self) -> impl Iterator<Item = (usize, &Vec<usize>)>
Iterates over all nodes in the graph.
Each item is a tuple of the node id and a Vec
of all its outgoing edges
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Number of nodes (vertices) in the graph