Skip to content

Commit f4d4644

Browse files
pre-commit-ci[bot]cclauss
authored andcommitted
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent bd440a0 commit f4d4644

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Diff for: graphs/check_bipatrite.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from collections import defaultdict, deque
22

3+
34
def is_bipartite_dfs(graph: defaultdict[int, list[int]]) -> bool:
45
"""
56
Check if a graph is bipartite using DFS.
@@ -19,6 +20,7 @@ def is_bipartite_dfs(graph: defaultdict[int, list[int]]) -> bool:
1920
>>> is_bipartite_dfs(defaultdict(list, {0: [1, 2], 1: [0, 3], 2: [0, 1]}))
2021
False
2122
"""
23+
2224
def dfs(node, color):
2325
"""
2426
Perform Depth-First Search (DFS) on the graph starting from a node.
@@ -43,6 +45,7 @@ def dfs(node, color):
4345
return False
4446
return True
4547

48+
4649
def is_bipartite_bfs(graph: defaultdict[int, list[int]]) -> bool:
4750
"""
4851
Check if a graph is bipartite using BFS.
@@ -77,6 +80,8 @@ def is_bipartite_bfs(graph: defaultdict[int, list[int]]) -> bool:
7780
elif visited[neighbor] == visited[curr_node]:
7881
return False
7982
return True
83+
84+
8085
if __name__ == "__main":
8186
import doctest
8287

@@ -85,4 +90,4 @@ def is_bipartite_bfs(graph: defaultdict[int, list[int]]) -> bool:
8590
if result.failed:
8691
print(f"{result.failed} test(s) failed.")
8792
else:
88-
print("All tests passed!")
93+
print("All tests passed!")

0 commit comments

Comments
 (0)