Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • \$\begingroup\$ Nice effort, but I do believe you are missing one component. What about the case where a node is surrounded by 5 different colors? \$\endgroup\$ Commented Aug 15, 2018 at 17:50
  • \$\begingroup\$ I'll try to build a test case to break this \$\endgroup\$ Commented Aug 15, 2018 at 17:51
  • \$\begingroup\$ Suppose that a given node in your graph is surrounded by 5 other nodes, which you've already colored the 5 colors you are allowed. \$\endgroup\$ Commented Aug 15, 2018 at 17:56
  • 1
    \$\begingroup\$ My code randomly generates graph colorings and checks them until it generates a correct graph coloring, which it then prints upon exiting. In the case you describe it'd start over and hopefully not color those 5 nodes all 5 available colors. \$\endgroup\$ Commented Aug 15, 2018 at 17:59
  • 2
    \$\begingroup\$ Now it checks all the colorings in lexicographic order :) so it's deterministic and O(5^n), but a lot slower for most inputs. \$\endgroup\$ Commented Aug 15, 2018 at 18:09