sankey.rs
use crate::{AnnotationGraph, Measurement, Variable};
pub fn nodes<'graph>(annotations: &'graph AnnotationGraph) -> Vec<&'graph str> {
annotations.packages().map(|node| node.name()).collect()
}
pub fn links<'graph>(annotations: &'graph AnnotationGraph) -> Vec<(&'graph str, &'graph str, f64)> {
let mut sankey_links = Vec::new();
for (source, target) in annotations.edges() {
let edge_weight =
annotations.variable(target, Variable::UnitDuration, Measurement::Relative);
sankey_links.push((source.name(), target.name(), edge_weight));
}
sankey_links
}