NetworkX

Previous topic

networkx.algorithms.bipartite.bipartite_sets

Next topic

networkx.algorithms.bipartite.project

networkx.algorithms.bipartite.bipartite_color

networkx.algorithms.bipartite.bipartite_color(G)

Returns a two-coloring of the graph.

Raises an exception if the graph is not bipartite.

Parameters :

G : NetworkX graph

Returns :

color : dictionary

A dictionary keyed by node with a 1 or 0 as data for each node color.

Examples

>>> G=nx.path_graph(4)
>>> c=nx.bipartite_color(G)
>>> print(c)
{0: 1, 1: 0, 2: 1, 3: 0}