MCPcopy Create free account
hub / github.com/google-deepmind/alphageometry / why_equal

Method why_equal

geometry.py:202–231  ·  view source on GitHub ↗

BFS why this node is equal to other nodes.

(self, others: list[Node], level: int)

Source from the content-addressed store, hash-verified

200 return parent
201
202 def why_equal(self, others: list[Node], level: int) -> list[Any]:
203 """BFS why this node is equal to other nodes."""
204 others = set(others)
205 found = 0
206
207 parent = {}
208 queue = [self]
209 i = 0
210
211 while i < len(queue):
212 current = queue[i]
213 if current in others:
214 found += 1
215 if found == len(others):
216 break
217
218 i += 1
219
220 for neighbor in current.merge_graph:
221 if (
222 level is not None
223 and current.merge_graph[neighbor].level is not None
224 and current.merge_graph[neighbor].level >= level
225 ):
226 continue
227 if neighbor not in parent:
228 queue.append(neighbor)
229 parent[neighbor] = current
230
231 return bfs_backtrack(self, others, parent)
232
233 def why_equal_groups(
234 self, groups: list[list[Node]], level: int

Callers 6

why_repMethod · 0.95
rep_and_whyMethod · 0.95
why_connectMethod · 0.95
why_valMethod · 0.45
is_equivFunction · 0.45
why_equalFunction · 0.45

Calls 1

bfs_backtrackFunction · 0.85

Tested by

no test coverage detected