graph_sparsifier/
common.rs

1use algograph::graph::*;
2use std::{
3    collections::{HashMap, HashSet},
4    hash::Hash,
5};
6
7pub fn norm_1<K: Ord + Hash>(v: &HashMap<K, f64, ahash::RandomState>) -> f64 {
8    v.values().map(|x| x.abs()).sum()
9}
10
11pub fn support(
12    p: &HashMap<VertexId, f64, ahash::RandomState>,
13) -> HashSet<VertexId, ahash::RandomState> {
14    p.iter()
15        .filter_map(|(vert, val)| {
16            if *val < -1e-7 || *val > 1e-7 {
17                Some(*vert)
18            } else {
19                None
20            }
21        })
22        .collect()
23}