Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add logic to plot the found path and show the start and the end #149

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion docs/EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,22 @@ Sometimes it is hard to see the finer points of a maze in plain text. You may wa

import matplotlib.pyplot as plt

def showPNG(grid):
def showPNG(grid, start=None, end=None, shortest_path=None):
"""Generate a simple image of the maze."""
plt.figure(figsize=(10, 5))
plt.imshow(grid, cmap=plt.cm.binary, interpolation='nearest')
plt.xticks([]), plt.yticks([])
# plot start and end
if start is not None:
plt.plot(start[1], start[0], 'o', markersize=10, color='green')
if end is not None:
plt.plot(end[1], end[0], 'o', markersize=10, color='red')
# plot the shortest path
if shortest_path is not None:
plt.plot([p[1] for p in shortest_path], [p[0] for p in shortest_path], linewidth=3, color='cyan')
plt.show()


![Prims Example](images/prims_5x5_plain.png?raw=true)


Expand Down
Loading