pub trait TraversableCollection<K, V>: MapCollection<K, V> + IntoTraverser<K>{
    type EdgeType;

    // Required methods
    fn degree_of(&self, key: K) -> isize;
    fn diameter(&self) -> f32;
    fn edge_list(&self) -> Vec<Self::EdgeType>;
    fn edges(&self) -> usize;
    fn has_cycle(&self) -> bool;
    fn is_bipartite(&self) -> bool;
    fn is_connected(&self) -> bool;
    fn is_neighbor(&self, key_a: K, key_b: K) -> bool;
    fn path_of(
        &mut self,
        key_a: K,
        key_b: K
    ) -> Option<DoublyLinkedList<KeyValue<usize, V>>>;
}

Required Associated Types§

source

type EdgeType

Edge type

Required Methods§

source

fn degree_of(&self, key: K) -> isize

Returns the degree of the ‘node’ with the specified key, or returns -1 if no such ‘node’ with that key exists. The degree of a ‘node’ is the number of ‘nodes’ it is connected to.

source

fn diameter(&self) -> f32

Returns the diameter of the ‘traversable collection’. The diameter of a ‘traversable collection’ is the longest path from one ‘node’ to another ‘node’.

source

fn edge_list(&self) -> Vec<Self::EdgeType>

Returns a list of the ‘edges’ in the ‘traversable collection’.

source

fn edges(&self) -> usize

Returns the number of edges in this ‘traversable collection’.

source

fn has_cycle(&self) -> bool

Returns true if the ‘traversable collection’ has a cycle within it. A cycle is where ‘nodes’ are connected together in a circular path.

source

fn is_bipartite(&self) -> bool

Returns true if the ‘traversable collection’ is a bipartite ‘graph’. A bipartite ‘graph’ is a graph that can be divided into two disjoint sets with no ‘node’ in either set connected to a ‘node’ in the same set.

source

fn is_connected(&self) -> bool

Returns true if every ‘node’ in the ‘traversable collection’ is connected to at least one other ‘node’.

source

fn is_neighbor(&self, key_a: K, key_b: K) -> bool

Returns true if the ‘node’ with the second specified key is a neighbor of the ‘node’ with the first specified key. If either key does not belong to an existing ‘node’, or the two ‘nodes’ are not neighbors, this returns false. A ‘node’ neighbor is a ‘node’ that is directly linked to the other ‘node’.

source

fn path_of( &mut self, key_a: K, key_b: K ) -> Option<DoublyLinkedList<KeyValue<usize, V>>>

Returns a ‘doubly linked list’ containing the path from the first specified key to the second specified key. Returns None if there is no path. The path contains the key/value pairs of each ‘node’ in the path and is stored in order from key_a at the start to key_b at the end.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<K, V> TraversableCollection<K, V> for Tree<K, V>

§

type EdgeType = Edge<K, true, false>

source§

impl<K, V, const BALANCED: bool> TraversableCollection<K, V> for BinaryTree<K, V, BALANCED>

§

type EdgeType = Edge<K, true, false>

source§

impl<V> TraversableCollection<usize, V> for DoublyLinkedList<V>

§

type EdgeType = Edge<usize, false, false>

source§

impl<V> TraversableCollection<usize, V> for LinkedList<V>

§

type EdgeType = Edge<usize, true, false>

source§

impl<V, const DIRECTED: bool, const WEIGHTED: bool> TraversableCollection<usize, V> for Graph<V, DIRECTED, WEIGHTED>

§

type EdgeType = Edge<usize, DIRECTED, WEIGHTED>