May 2019
Intermediate to advanced
698 pages
17h 21m
English
In order to get a head start on these requirements, the decision for a graph representation has to be made: list or matrix? Both work well, but for explanatory reasons, the examples will go with an adjacency list built on top of a vector of vectors:
pub struct InternetOfThings { adjacency_list: Vec<Vec<Edge>>, nodes: Vec<KeyType>,}
As previously mentioned, it makes sense to keep the actual values, identifiers, or even entire objects in their own list and simply work with indices of the usize type. The edge structure in this example could be represented as a tuple just as well, but it's way more readable this way:
#[derive(Clone, Debug)]struct Edge { weight: u32, node: usize,}
Having those two structures in place, ...
Read now
Unlock full access