def is_bipartite_node_set(G, nodes):
 S = set(nodes)
 for CC in nx.connected_component_subgraphs(G):
  (X, Y) = sets(CC)
  if (not ((X.issubset(S) and Y.isdisjoint(S)) or (Y.issubset(S) and X.isdisjoint(S)))):
   return False
 return True

def is_bipartite_node_set ( G , nodes ) : S = set ( nodes ) for CC in nx . connected_component_subgraphs ( G ) : ( X , Y ) = sets ( CC ) if ( not ( ( X . issubset ( S ) and Y . isdisjoint ( S ) ) or ( Y . issubset ( S ) and X . isdisjoint ( S ) ) ) ) : return False return True
returns true if nodes and g/nodes are a bipartition of g .