Golang implementation of the voronoi diagram
This is a graphical representation of a voronoi diagram written in Go.
Run the bin without any parameters: ./voronoi
Some parameters may be customized here, in this case you can run the source (go run .
) or rebuild (go build .
) and run the bin ./voronoi
Space
: restarts the simulation generating a new set of seeds
Enter
: starts/stops the simulation
This solution implements an approximated (but enough accurate) algorithm to solve the voronoi diagram problem.
Basically it works by extending the cells starting from the seed points: at each iteration, the size of the cell is incremented and each point laying in this incremental perimeter is assigned to the cell (unless it is already assigned to a closed seed).
Each cell is extended until no more points can be assigned to it. At that point the cell is flagged as inactive
and ignored in the following iterations.
The algorithm goes on until there are no more active cells, meaning all the points in the canvas have been assigned to a cell.
Because it is in a sweet spot between the simple but highly inefficient brute force algorithm (that for each point in the canvas finds its nearest seed,) and the Fortune's Algorithm, efficient but complex