Python problem representation
To encapsulate the graph coloring problem, we've created a Python class called GraphColoringProblem. This class can be found in the graphs.py file, which can be found at https://github.com/PacktPublishing/Hands-On-Genetic-Algorithms-with-Python/blob/master/Chapter05/graphs.py.
To implement this class, we utilized the open source Python package NetworkX (https://networkx.github.io), which enables, among the rest, the creation, manipulation, and drawing of graphs. The graph we use as the subject of the coloring problem is an instance of the NetworkX graph class. Instead of creating this graph from scratch, we can take advantage of the numerous preexisting graphs contained in this library, such as the Petersen graph ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access