Skip to content

Commit 2791920

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent b21086d commit 2791920

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

graphs/bidirectional_search.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@
1414
from collections import deque
1515

1616

17-
def expand_search(graph: dict[int, list[int]], queue: deque[int], parents: dict[int, int | None], opposite_direction_parents: dict[int, int | None]) -> int | None:
17+
def expand_search(
18+
graph: dict[int, list[int]],
19+
queue: deque[int],
20+
parents: dict[int, int | None],
21+
opposite_direction_parents: dict[int, int | None],
22+
) -> int | None:
1823
if not queue:
1924
return None
2025

@@ -98,13 +103,23 @@ def bidirectional_search(
98103
# Continue until both queues are empty or an intersection is found
99104
while forward_queue and backward_queue and intersection is None:
100105
# Expand forward search
101-
intersection = expand_search(graph=graph, queue=forward_queue, parents=forward_parents, opposite_direction_parents=backward_parents)
106+
intersection = expand_search(
107+
graph=graph,
108+
queue=forward_queue,
109+
parents=forward_parents,
110+
opposite_direction_parents=backward_parents,
111+
)
102112

103113
# If no intersection found, expand backward search
104114
if intersection is not None:
105115
break
106116

107-
intersection = expand_search(graph=graph, queue=backward_queue, parents=backward_parents, opposite_direction_parents=forward_parents)
117+
intersection = expand_search(
118+
graph=graph,
119+
queue=backward_queue,
120+
parents=backward_parents,
121+
opposite_direction_parents=forward_parents,
122+
)
108123

109124
# If no intersection found, there's no path
110125
if intersection is None:

0 commit comments

Comments
 (0)