rustworkx.two_color#

two_color(graph)[source]#

Compute a two-coloring of a directed graph

If a two coloring is not possible for the input graph (meaning it is not bipartite), None is returned.

Parameters:

graph – The graph to find the coloring for

Returns:

If a coloring is possible return a dictionary of node indices to the color as an integer (0 or 1)

Return type:

dict