MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / get_successors

Method get_successors

graphs/greedy_best_first.py:147–166  ·  view source on GitHub ↗

Returns a list of successors (both in the grid and free spaces)

(self, parent: Node)

Source from the content-addressed store, hash-verified

145 return None
146
147 def get_successors(self, parent: Node) -> list[Node]:
148 """
149 Returns a list of successors (both in the grid and free spaces)
150 """
151 return [
152 Node(
153 pos_x,
154 pos_y,
155 self.target.pos_x,
156 self.target.pos_y,
157 parent.g_cost + 1,
158 parent,
159 )
160 for action in delta
161 if (
162 0 <= (pos_x := parent.pos_x + action[1]) < len(self.grid[0])
163 and 0 <= (pos_y := parent.pos_y + action[0]) < len(self.grid)
164 and self.grid[pos_y][pos_x] == 0
165 )
166 ]
167
168 def retrace_path(self, node: Node | None) -> Path:
169 """

Callers 1

searchMethod · 0.95

Calls 1

NodeClass · 0.70

Tested by

no test coverage detected