Add Extra edge cases (#12995)

* Add Extra edge cases

* Update coloring.py

---------

Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
This commit is contained in:
Thrive
2026-03-12 10:30:21 +05:30
committed by GitHub
parent 135c748e55
commit c34f23e47e

View File

@@ -104,6 +104,14 @@ def color(graph: list[list[int]], max_colors: int) -> list[int]:
>>> max_colors = 2
>>> color(graph, max_colors)
[]
>>> color([], 2) # empty graph
[]
>>> color([[0]], 1) # single node, 1 color
[0]
>>> color([[0, 1], [1, 0]], 1) # 2 nodes, 1 color (impossible)
[]
>>> color([[0, 1], [1, 0]], 2) # 2 nodes, 2 colors (possible)
[0, 1]
"""
colored_vertices = [-1] * len(graph)