Skip to content

Commit b1ae455

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

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

backtracking/m_coloring_problem.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
def is_safe(node: int, color: int, graph: list[list[int]], num_vertices: int, col: list[int]) -> bool:
1+
def is_safe(
2+
node: int, color: int, graph: list[list[int]], num_vertices: int, col: list[int]
3+
) -> bool:
24
"""
35
Check if it is safe to assign a color to a node.
46
@@ -7,10 +9,18 @@ def is_safe(node: int, color: int, graph: list[list[int]], num_vertices: int, co
79
>>> is_safe(0, 2, [[0,1],[1,0]], 2, [0,1])
810
True
911
"""
10-
return all(not (graph[node][k] == 1 and col[k] == color) for k in range(num_vertices))
12+
return all(
13+
not (graph[node][k] == 1 and col[k] == color) for k in range(num_vertices)
14+
)
1115

1216

13-
def solve(node: int, col: list[int], max_colors: int, num_vertices: int, graph: list[list[int]]) -> bool:
17+
def solve(
18+
node: int,
19+
col: list[int],
20+
max_colors: int,
21+
num_vertices: int,
22+
graph: list[list[int]],
23+
) -> bool:
1424
"""
1525
Recursively try to color the graph using at most max_colors.
1626

0 commit comments

Comments
 (0)