Created
March 27, 2018 02:46
-
-
Save LukeWood/47ce7cf832ffafa523378027e1dbab3f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def color_graph(ordering, adj_list): | |
coloring = [-1 for _ in ordering] | |
for node in ordering: | |
color = 0 | |
used_colors = set([coloring[neighbor] for neighbor in adj_list[node]]) | |
while color in used_colors: | |
color = color + 1 | |
coloring[node] = color | |
return coloring |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment