Optimization, Operations Research, Python, Data Science, Editors Pick.
Q = [n for n in self.N] # Pool of uncolored nodes while len(Q) > 0: Q.sort(key=lambda x: (x.saturation, x.degree), reverse=True) n: Node = Q.pop(0) next_color = self.find_next_color(n) n.set_color(next_color) if save_history: self.history.append(n) self.C.sort(key=lambda x: x.n_nodes, reverse=True)