equitable_color(G, num_colors)
Attempts to color a graph using r colors, where no neighbors of a node can have same color as the node itself and the number of nodes with each color differ by at most 1.
The nodes of this graph will be colored.
This number must be at least one more than the maximum degree of nodes in the graph.
If the maximum degree of the graph G
is greater than num_colors
.
Provides equitable (r + 1)-coloring for nodes of G in O(r * n^2) time if deg(G) <= r. The algorithm is described in .
>>> G = nx.cycle_graph(4)See :
... d = nx.coloring.equitable_color(G, num_colors=3)
... nx.algorithms.coloring.equitable_coloring.is_equitable(G, d) True
The following pages refer to to this document either explicitly or contain code examples using this.
networkx.algorithms.coloring.equitable_coloring.equitable_color
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them