Generate Maze with Kruskal algorithm by Canvas API
There is a lot of algorithms for maze generation purpose, such as Depth-first search, Prim, Wilson, Aldous-Broder,... But I used Kruskal for nothing.
In the beginning, we have sets of the cell (called forest), each contains just one cell and a set of edges. With each edge, we have two cells neighbored. If these cells in a different forest, merging two forests. If not, just ignore them.
For presentation sets of the cell, we use the Disjoint-set data structure. With the edges, a simple queue is enough.
- You can found my code at: Maze Generation source code
- Live demo: Maze Generation demo
- Latest live demo: Maze Generation demo (github)
By: Anh Hao