networkx 2.8.2 Pypi GitHub Homepage
Other Docs
ParametersRaisesReturnsBackRef
color(G)

Raises an exception if the graph is not bipartite.

Parameters

G : NetworkX graph

Raises

NetworkXError

If the graph is not two-colorable.

Returns

color : dictionary

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

Returns a two-coloring of the graph.

Examples

>>> from networkx.algorithms import bipartite
... G = nx.path_graph(4)
... c = bipartite.color(G)
... print(c) {0: 1, 1: 0, 2: 1, 3: 0}

You can use this to set a node attribute indicating the biparite set:

>>> nx.set_node_attributes(G, c, "bipartite")
... print(G.nodes[0]["bipartite"]) 1
>>> print(G.nodes[1]["bipartite"])
0
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

networkx.algorithms.bipartite.spectral.spectral_bipartivity networkx.algorithms.bipartite.basic.is_bipartite networkx.algorithms.bipartite.basic.sets networkx.algorithms.bipartite.basic.color networkx.algorithms.bipartite.basic.degrees networkx.algorithms.bipartite.basic.density

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /networkx/algorithms/bipartite/basic.py#20
type: <class 'function'>
Commit: