NetworkX

Previous topic

networkx.bipartite_sets

Next topic

networkx.project

networkx.bipartite_color

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}