extract_bipartite_subgraph
(function from pyomo.contrib.incidence_analysis.interface
)
- pyomo.contrib.incidence_analysis.interface.extract_bipartite_subgraph(graph, nodes0, nodes1)[source]
Return the bipartite subgraph of a graph.
Two lists of nodes to project onto must be provided. These will correspond to the “bipartite sets” in the subgraph. If the two sets provided have M and N nodes, the subgraph will have nodes 0 through M+N-1, with the first M corresponding to the first set provided and the last N corresponding to the second set.
- Parameters:
graph (NetworkX Graph) – The graph from which a subgraph is extracted
nodes0 (list) – A list of nodes in the original graph that will form the first bipartite set of the projected graph (and have
bipartite=0
)nodes1 (list) – A list of nodes in the original graph that will form the second bipartite set of the projected graph (and have
bipartite=1
)
- Returns:
subgraph – Graph containing integer nodes corresponding to positions in the provided lists, with edges where corresponding nodes are adjacent in the original graph.
- Return type:
networkx.Graph