Trait Edge

Source
pub trait Edge<K, W, C>
where K: Hash + Eq + Clone, C: Hash + Eq + Clone, W: Add + Sub + Eq + Ord + Copy,
{ // Required methods fn get_weight(&self) -> W; fn set_weight(&mut self, weight: W); fn left(&self) -> &K; fn right(&self) -> &K; fn get_pair(&self) -> (&K, &K); fn generate_key(pair: (&K, &K)) -> C; fn key(&self) -> C; }
Expand description

Generic behaviour of an edge

Generic type C is the key type of the edge

Generic type K is the key type of the vertexes connected by the edge

Generic type W is

Required Methods§

Source

fn get_weight(&self) -> W

Source

fn set_weight(&mut self, weight: W)

Source

fn left(&self) -> &K

Source

fn right(&self) -> &K

Source

fn get_pair(&self) -> (&K, &K)

This pair must not be used as a key for the edge, this must instead be used to generate the key or to construct a new edge

Source

fn generate_key(pair: (&K, &K)) -> C

An associated function constructing the edge key from a pair of vertex keys must be implemented for the edge tipe

the key returned by the key(&self) method must correspond to the key generated by said function with the pair of keys returned by the method get_pair(&self)

Source

fn key(&self) -> C

The key returned by this method must correspond to the key generated by passing the pair of keys returned by get_pair(&self) to rhe associated function generate_key(pair: (&T, &T))

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<K: Hash + Eq + Clone, W: Add + Sub + Eq + Ord + Copy> Edge<K, W, CompoundKey<K>> for DirectedEdge<K, W>

DirectedEdge implement the Edge trait Specifying the edge key type (CompoundKey). But the vertex key type and the edge weight type remain generics.