Return the projection of the graph onto a subset of nodes.
The nodes retain their names and are connected in the resulting graph if have an edge to a common node in the original graph.
Parameters: | B : NetworkX graph
nodes : list or iterable
|
---|---|
Returns: | Graph : NetworkX graph
|
See also
Notes
Returns a graph that is the projection of the bipartite graph B onto the set of nodes given in list nodes. No attempt is made to verify that the input graph B is bipartite.
Examples
>>> B=nx.path_graph(4)
>>> G=nx.project(B,[1,3])
>>> print G.nodes()
[1, 3]
>>> print G.edges()
[(1, 3)]