Note

This is the documentation for the current state of the development branch of rustworkx. The documentation or APIs here can change prior to being released.

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