This documents the development version of NetworkX. Documentation for the current release can be found here.
Returns bipartite node sets of graph G.
Raises an exception if the graph is not bipartite or if the input graph is disconnected and thus more than one valid solution exists. See
bipartite documentationfor further details on how bipartite graphs are handled in NetworkX.
- GNetworkX graph
- top_nodescontainer, optional
Container with all nodes in one bipartite node set. If not supplied it will be computed. But if more than one solution exists an exception will be raised.
Nodes from one side of the bipartite graph.
Nodes from the other side.
Raised if the input bipartite graph is disconnected and no container with all nodes in one bipartite set is provided. When determining the nodes in each bipartite set more than one valid solution is possible if the input graph is disconnected.
Raised if the input graph is not bipartite.
>>> from networkx.algorithms import bipartite >>> G = nx.path_graph(4) >>> X, Y = bipartite.sets(G) >>> list(X) [0, 2] >>> list(Y) [1, 3]