NetworkX

Previous topic

networkx.bipartite_color

Next topic

Blockmodeling

networkx.project

project(B, nodes, create_using=None)

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

The input graph should be bipartite.

nodes : list or iterable

Nodes to project onto.

Returns:

Graph : NetworkX graph

A graph that is the projection onto the given nodes.

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)]