1
0
forked from extern/smegmesh

Implemented clustering betweeen nodes

This commit is contained in:
Tim Beatham
2023-11-03 15:24:18 +00:00
parent 8d8a13d6ff
commit 843caddf6b
10 changed files with 102 additions and 46 deletions

View File

@@ -1,6 +1,8 @@
package lib
import "math/rand"
import (
"math/rand"
)
// RandomSubsetOfLength: Given an array of nodes generate of random
// subset of 'num' length.
@@ -17,6 +19,7 @@ func RandomSubsetOfLength[V any](vs []V, num int) []V {
if _, ok := selectedIndices[randomIndex]; !ok {
randomSubset = append(randomSubset, vs[randomIndex])
selectedIndices[randomIndex] = struct{}{}
i++
}
}