Sync
This commit is contained in:
parent
6f050a029e
commit
776bba907c
3887 changed files with 59894 additions and 7280 deletions
|
|
@ -1,11 +1,11 @@
|
|||
MazeGraph[m_, n_] :=
|
||||
Block[{$RecursionLimit = Infinity, grid = GridGraph[{m, n}],
|
||||
visited = {}},
|
||||
Graph[Range[m n], Reap[{AppendTo[visited, #];
|
||||
Do[
|
||||
If[FreeQ[visited, neighbor],
|
||||
Sow[# <-> neighbor]; #0@neighbor], {neighbor,
|
||||
RandomSample@AdjacencyList[grid, #]}]} &@
|
||||
RandomChoice@VertexList@grid][[2, 1]],
|
||||
GraphLayout -> {"GridEmbedding", "Dimension" -> {m, n}}]];
|
||||
Block[{$RecursionLimit = Infinity, grid = GridGraph[{m, n}],
|
||||
unvisitedQ}, unvisitedQ[_] := True;
|
||||
Graph[Range[m n], Reap[{unvisitedQ[#] = False;
|
||||
Do[
|
||||
If[unvisitedQ[neighbor],
|
||||
Sow[# <-> neighbor]; #0@neighbor], {neighbor,
|
||||
RandomSample@AdjacencyList[grid, #]}]} &@
|
||||
RandomChoice@VertexList@grid][[2, 1]],
|
||||
GraphLayout -> {"GridEmbedding", "Dimension" -> {m, n}}]];
|
||||
maze = MazeGraph[13, 21]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue