pub(crate) fn filter(&self, k: usize) -> AdjacencyList {
        let mut new_offsets = self.offsets.clone();
        let mut accum = 0;
        for v in 0..self.nvertices() {
            for i in self.offsets[v]..self.offsets[v + 1] {
                if self.freqs[i] < k {
                    accum += 1;
                }
            }
            new_offsets[v + 1] -= accum;
        }
        let (nbrs, freqs): (Vec<_>, Vec<_>) = self
            .all_neighbors
            .iter()
            .copied()
            .zip(self.freqs.iter().copied())
            .filter(|(_, f)| *f >= k)
            .unzip();
        Self {
            offsets: new_offsets,
            all_neighbors: nbrs,
            freqs,
        }
    }
/// Filter a graph to edges that occur at least k times. Note this may result in
/// isolated vertices.
Filter a graph to edges that occur at least k times. Note this may result in
isolated vertices.
Filter a graph to edges that occur at least k times . Note this may result in isolated vertices .
pub(crate) fn filter(&self, k: usize) -> AdjacencyList {
        let mut new_offsets = self.offsets.clone();
        let mut accum = 0;
        for v in 0..self.nvertices() {
            for i in self.offsets[v]..self.offsets[v + 1] {
                if self.freqs[i] < k {
                    accum += 1;
                }
            }
            new_offsets[v + 1] -= accum;
        }
        let (nbrs, freqs): (Vec<_>, Vec<_>) = self
            .all_neighbors
            .iter()
            .copied()
            .zip(self.freqs.iter().copied())
            .filter(|(_, f)| *f >= k)
            .unzip();
        Self {
            offsets: new_offsets,
            all_neighbors: nbrs,
            freqs,
        }
    }
pub ( crate ) fn filter ( & self , k : usize ) -> AdjacencyList { let mut new_offsets = self . offsets . clone ( ) ; let mut accum = 0 ; for v in 0 .. self . nvertices ( ) { for i in self . offsets [ v ] .. self . offsets [ v + 1 ] { if self . freqs [ i ] < k { accum += 1 ; } } new_offsets [ v + 1 ] -= accum ; } let ( nbrs , freqs ) : ( Vec < _ > , Vec < _ > ) = self . all_neighbors . iter ( ) . copied ( ) . zip ( self . freqs . iter ( ) . copied ( ) ) . filter ( | ( _ , f ) | * f >= k ) . unzip ( ) ; Self { offsets : new_offsets , all_neighbors : nbrs , freqs , } }
Filter a graph to edges that occur at least k times.
Filter a graph to edges that occur at least k times .
&self
k
usize
&self
k
usize