Skip to main content

Module node

Module node 

Source
Expand description

This modules defines types and traits for a graph node

§TheNode type

Node type plays a central role in this suite.

Each Node has an id and a weight, both generic over types implementing NodeId and NodeWeight traits respectively. Both have blanket implementations over generic types so you can use any types you want as long as it implements the required traits

use dijkstra_suite::node::Node;

let node_a: Node<(i32, i32), f64> = Node {
    weight: 1.0,
    ..Default::default()
};

let node_b = Node {
    id: (0, 0),
    weight: 1.0,
    neighbours: vec![],
};

let node_c: Node<(i32, i32), f32> = Node::default();

assert_eq!(node_a, node_b);
assert_eq!(node_c.weight, 0.0)

§TheNodeId trait

Nodeid is a super trait that ensures the id of the node is comparable and hashable (current implementation uses an HashMap under the hood), requiring the implementing type also to implement Hash, Eq and Default

§TheNodeWeight trait

NodeWeight is a super trait that ensures the weight of the node is a number or number-like types, requiring the implementing type also to implement Add, Div, Mul, Rem, Sub and PartialEq

Structs§

Node
NodeConnection

Traits§

NodeId
NodeWeight