Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit53e3385

Browse files
committed
Updated pathfinding to calculate groups
1 parenteff324a commit53e3385

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

‎2018/pathfinding.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,25 @@ def add_walls(self, vertices):
172172

173173
returnchanged
174174

175+
defdfs_groups(self):
176+
"""
177+
Groups vertices based on depth-first search
178+
179+
:return: A list of groups
180+
"""
181+
groups= []
182+
unvisited=self.vertices.copy()
183+
184+
whileunvisited:
185+
start=unvisited.pop()
186+
self.depth_first_search(start)
187+
188+
newly_visited=list(self.distance_from_start.keys())
189+
unvisited= [xforxinunvisitedifxnotinnewly_visited]
190+
groups.append(newly_visited)
191+
192+
returngroups
193+
175194
defdepth_first_search(self,start,end=None):
176195
"""
177196
Performs a depth-first search based on a start node

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp