Skip to content

Instantly share code, notes, and snippets.

@ivank2139
Created October 26, 2020 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivank2139/90190c4088509562c8d4ee48aa336434 to your computer and use it in GitHub Desktop.
Save ivank2139/90190c4088509562c8d4ee48aa336434 to your computer and use it in GitHub Desktop.
Generates 26 named nodes using random x y coordinates
func GenNodes() string {
var sbldr = strings.Builder{}
for _, node := range NodeNames {
x := decimal.NewFromInt(int64(rand.Intn(GridMax-GridMin) + GridMin))
y := decimal.NewFromInt(int64(rand.Intn(GridMax-GridMin) + GridMin))
if !colocation(x, y) {
Nodes[node] = *NewNode(node, x, y)
} else {
log.Error.Println("Found colocated instance")
}
}
sbldr.WriteString("\n\nGenerated " + strconv.Itoa(len(Nodes)) + " named nodes with random x y data points between " +
strconv.Itoa(GridMin) + " and " + strconv.Itoa(GridMax))
return sbldr.String()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment