[][src]Trait generic_graph::Edge

pub trait Edge<K, W, C> where
    K: Hash + Eq + Clone,
    C: Hash + Eq + Clone,
    W: Add + Sub + Eq + Ord + Copy
{ 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; }

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

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)

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

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)

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))

Loading content...

Implementors

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

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

fn get_weight(&self) -> W[src]

Returns a copy of the weight (the weight type is required to implement Copy)

fn set_weight(&mut self, weight: W)[src]

change the value of weight

fn left(&self) -> &K[src]

Returns a reference to the key of the left hand vertex

fn right(&self) -> &K[src]

Returns a reference to the key of the right hand vertex

fn get_pair(&self) -> (&K, &K)[src]

Returns a pair of reference to the vertex keys. Ordered from left to right

fn generate_key(pair: (&K, &K)) -> CompoundKey<K>[src]

Returns a new instance of CompoundKey from a pair of reference to vertex keys

Example

use generic_graph::adjacency_list::elements::DirectedEdge;
use generic_graph::Edge;

let edge = DirectedEdge::new(1, 2, 3);
let key = DirectedEdge::<i32, i32>::generate_key(edge.get_pair());

assert_eq!(key, edge.key());

fn key(&self) -> CompoundKey<K>[src]

Returns an new instance of CompoundKey generated from the pair of keys stored isn the edge

Example

use generic_graph::adjacency_list::elements::DirectedEdge;
use generic_graph::Edge;

let edge = DirectedEdge::new(1, 2, 3);
let key = DirectedEdge::<i32, i32>::generate_key(edge.get_pair());

assert_eq!(key, edge.key());
Loading content...