pub fn min_spanning_tree(&self, weights: &[i64]) -> Vec<usize> {
        assert_eq!(self.num_e(), 2 * weights.len());
        let mut edges = (0..weights.len()).collect::<Vec<_>>();
        edges.sort_by_key(|&e| weights[e]);

        let mut components = DisjointSets::new(self.num_v());
        edges
            .into_iter()
            .filter(|&e| {
                components.merge(self.endp[2 * e], self.endp[2 * e + 1])
            })
            .collect()
    }
/// Kruskal's minimum spanning tree algorithm on an undirected graph.
Kruskal's minimum spanning tree algorithm on an undirected graph.
Kruskal ' s minimum spanning tree algorithm on an undirected graph .
pub fn min_spanning_tree(&self, weights: &[i64]) -> Vec<usize> {
        assert_eq!(self.num_e(), 2 * weights.len());
        let mut edges = (0..weights.len()).collect::<Vec<_>>();
        edges.sort_by_key(|&e| weights[e]);
        let mut components = DisjointSets::new(self.num_v());
        edges
            .into_iter()
            .filter(|&e| {
                components.merge(self.endp[2 * e], self.endp[2 * e + 1])
            })
            .collect()
    }
pub fn min_spanning_tree ( & self , weights : & [ i64 ] ) -> Vec < usize > { assert_eq ! ( self num_e ( ) 2 weights len ( ) ) ; let mut edges = ( 0 .. weights . len ( ) ) . collect :: < Vec < _ > > ( ) ; edges . sort_by_key ( | & e | weights [ e ] ) ; let mut components = DisjointSets :: new ( self . num_v ( ) ) ; edges . into_iter ( ) . filter ( | & e | { components . merge ( self . endp [ 2 * e ] , self . endp [ 2 * e + 1 ] ) } ) . collect ( ) }
Kruskal's minimum spanning tree algorithm on an undirected graph.
Kruskal ' s minimum spanning tree algorithm on an undirected graph .
&self
weights
&[i64]
&self
weights
&[i64]