mirror of
https://github.com/TheAlgorithms/Python.git
synced 2026-03-13 09:50:19 +08:00
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:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user