pub struct AdjList<N>{ /* private fields */ }Expand description
Graph represented as Adjacency list. Directly support both direct and undirect graphs. This representation offers a minimal memory foot print - it keeps information only about existing arcs - at the cost of some inefficiencies in some opertations. The memory footprint of an AdJList is always O(|N|) + O(|A|), where |N| is the number of nodes and |A| is the number of arcs in the graph.
Implementations§
Source§impl<N> AdjList<N>
impl<N> AdjList<N>
Sourcepub fn new_direct(node_count: usize) -> Self
pub fn new_direct(node_count: usize) -> Self
Create a new direct graph with the given number of nodes. The resulting graph will NOT contain arcs. All nodes’ weights are set to num_traits::Num::zero()
Sourcepub fn new_undirect(node_count: usize) -> Self
pub fn new_undirect(node_count: usize) -> Self
Create a new undirect graph with the given number of nodes. The resulting graph will NOT contain arcs. All nodes’ weights are set to num_traits::Num::zero()
Sourcepub fn node_iterator(&self) -> impl Iterator<Item = (usize, N)> + '_
pub fn node_iterator(&self) -> impl Iterator<Item = (usize, N)> + '_
Return an iterator over the nodes.
Sourcepub fn arc_iterator(&self) -> impl Iterator<Item = (usize, usize, N)> + '_
pub fn arc_iterator(&self) -> impl Iterator<Item = (usize, usize, N)> + '_
Return an iterator over all the arcs in the graph.
Trait Implementations§
Source§impl<'de, N> Deserialize<'de> for AdjList<N>
impl<'de, N> Deserialize<'de> for AdjList<N>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<N> GetGraphType for &AdjList<N>
impl<N> GetGraphType for &AdjList<N>
fn graph_type(&self) -> GraphType
Source§impl<N> GetGraphType for AdjList<N>
impl<N> GetGraphType for AdjList<N>
fn graph_type(&self) -> GraphType
Source§impl<N> Graph<N> for AdjList<N>
impl<N> Graph<N> for AdjList<N>
Source§fn new(node_count: usize, gtype: GraphType) -> Self
fn new(node_count: usize, gtype: GraphType) -> Self
Source§fn add_new_default_arc(&mut self, src: usize, dst: usize)
fn add_new_default_arc(&mut self, src: usize, dst: usize)
src to dst (and from dst to src if the graph is undirected)
and associtate with this new arc the cost num_traits::Num::zero()Source§fn add_new_arc(&mut self, src: usize, dst: usize, weight: N)
fn add_new_arc(&mut self, src: usize, dst: usize, weight: N)
src to dst (and from dst to src if the graph is undirected)
and associtate with this new arc the cost weight