// find set of n1 and n2, then union the two sets into one
find set of n1 and n2, then union the two sets into one
// find set of n1 and n2 then union the two sets into one
func (s *sets) union(n1, n2 graph.NodeID) {
	id1 := s.find(n1)
	id2 := s.find(n2)
	if id1 == invalidSetID && id2 == invalidSetID {
		newSet := map[graph.NodeID]struct{}{}
		newSet[n1] = struct{}{}
		newSet[n2] = struct{}{}
		s.s[s.count] = newSet
		s.count++ 
		return
	}
	if id1 == invalidSetID { 
		s.s[id2][n1] = struct{}{}
		return
	}
	if id2 == invalidSetID { 
		s.s[id1][n2] = struct{}{}
		return
	}
	for k, v := range s.s[id2] {
		s.s[id1][k] = v
	}
	delete(s.s, id2)
}
func ( s * sets ) union ( n1 , n2 graph . NodeID ) { id1 := s . find ( n1 ) id2 := s . find ( n2 ) if id1 == invalidSetID && id2 == invalidSetID { newSet := map [ graph . NodeID ] struct { } { } newSet [ n1 ] = struct { } { } newSet [ n2 ] = struct { } { } s . s [ s . count ] = newSet s . count ++ return } if id1 == invalidSetID { s . s [ id2 ] [ n1 ] = struct { } { } return } if id2 == invalidSetID { s . s [ id1 ] [ n2 ] = struct { } { } return } for k , v := range s . s [ id2 ] { s . s [ id1 ] [ k ] = v } delete ( s . s , id2 ) }
find set of n1 and n2, then union the two sets into one
find set of n1 and n2 then union the two sets into one
// will small than g.NodeCount() // id2 != invalideSetID // id1 != invalideSetID //both id1 and id2 not invalid, // move all nodes into set1, then delete set2