rustworkx.graph_greedy_edge_color#
- graph_greedy_edge_color(graph, /)#
Color edges of a
PyGraph
object using a greedy approach.This function works by greedily coloring the line graph of the given graph.
- Parameters:
PyGraph – The input PyGraph object to edge-color
- Returns:
A dictionary where keys are edge indices and the value is the color
- Return type:
dict
import rustworkx as rx graph = rx.generators.cycle_graph(7) edge_colors = rx.graph_greedy_edge_color(graph) assert edge_colors == {0: 0, 1: 1, 2: 0, 3: 1, 4: 0, 5: 1, 6: 2}