aryagraph.algorithms.coloring.greedy_color#
- aryagraph.algorithms.coloring.greedy_color(g: Graph, strategy: str | Callable[[Graph], Iterable[Hashable]] = 'largest_first', *, seed: Any = None) NodeMap[source]#
A proper vertex coloring by the greedy method: each node takes the smallest free color.
- Parameters:
strategy – The order nodes are colored in:
"largest_first": decreasing degree (graph order breaks ties);"smallest_last": repeatedly strip a minimum-degree node, color in reverse (uses at most degeneracy + 1 colors);"dsatur"(alias"saturation_largest_first"): next is the node seeing the most distinct colors, then the highest degree;"independent_set": peel off maximal independent sets (min-degree first), one color each;"random_sequential": a random order drawn from seed;"connected_sequential_bfs"/"connected_sequential_dfs": BFS / DFS order within each component;"insertion": graph order;a callable
f(g)returning every node once, in the order to color.
- Returns:
NodeMap –
{node: color}in graph order. Never uses more than max degree + 1 colors.