From 6341f351aab0ff510fcf1d9ce135be680763a971 Mon Sep 17 00:00:00 2001 From: DukicDev Date: Fri, 1 Oct 2021 23:48:47 +0200 Subject: [PATCH] Fix comments in backtracking/coloring.py (#4857) --- backtracking/coloring.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/backtracking/coloring.py b/backtracking/coloring.py index 8bda4b587..9d539de8a 100644 --- a/backtracking/coloring.py +++ b/backtracking/coloring.py @@ -1,7 +1,7 @@ """ Graph Coloring also called "m coloring problem" - consists of coloring given graph with at most m colors - such that no adjacent vertices are assigned same color + consists of coloring a given graph with at most m colors + such that no adjacent vertices are assigned the same color Wikipedia: https://en.wikipedia.org/wiki/Graph_coloring """ @@ -11,9 +11,9 @@ def valid_coloring( neighbours: list[int], colored_vertices: list[int], color: int ) -> bool: """ - For each neighbour check if coloring constraint is satisfied + For each neighbour check if the coloring constraint is satisfied If any of the neighbours fail the constraint return False - If all neighbours validate constraint return True + If all neighbours validate the constraint return True >>> neighbours = [0,1,0,1,0] >>> colored_vertices = [0, 2, 1, 2, 0] @@ -41,14 +41,14 @@ def util_color( Base Case: 1. Check if coloring is complete - 1.1 If complete return True (meaning that we successfully colored graph) + 1.1 If complete return True (meaning that we successfully colored the graph) Recursive Step: - 2. Itterates over each color: - Check if current coloring is valid: + 2. Iterates over each color: + Check if the current coloring is valid: 2.1. Color given vertex - 2.2. Do recursive call check if this coloring leads to solving problem - 2.4. if current coloring leads to solution return + 2.2. Do recursive call, check if this coloring leads to a solution + 2.4. if current coloring leads to a solution return 2.5. Uncolor given vertex >>> graph = [[0, 1, 0, 0, 0],