This documents the development version of NetworkX. Documentation for the current release can be found here.


weighted_projected_graph(B, nodes, ratio=False)[source]

Returns a weighted projection of B onto one of its node sets.

The weighted projected graph is the projection of the bipartite network B onto the specified nodes with weights representing the number of shared neighbors or the ratio between actual shared neighbors and possible shared neighbors if ratio is True [1]. The nodes retain their attributes and are connected in the resulting graph if they have an edge to a common node in the original graph.

BNetworkX graph

The input graph should be bipartite.

nodeslist or iterable

Nodes to project onto (the “bottom” nodes).

ratio: Bool (default=False)

If True, edge weight is the ratio between actual shared neighbors and maximum possible shared neighbors (i.e., the size of the other node set). If False, edges weight is the number of shared neighbors.

GraphNetworkX graph

A graph that is the projection onto the given nodes.


No attempt is made to verify that the input graph B is bipartite. The graph and node properties are (shallow) copied to the projected graph.

See bipartite documentation for further details on how bipartite graphs are handled in NetworkX.



Borgatti, S.P. and Halgin, D. In press. “Analyzing Affiliation Networks”. In Carrington, P. and Scott, J. (eds) The Sage Handbook of Social Network Analysis. Sage Publications.


>>> from networkx.algorithms import bipartite
>>> B = nx.path_graph(4)
>>> G = bipartite.weighted_projected_graph(B, [1, 3])
>>> list(G)
[1, 3]
>>> list(G.edges(data=True))
[(1, 3, {'weight': 1})]
>>> G = bipartite.weighted_projected_graph(B, [1, 3], ratio=True)
>>> list(G.edges(data=True))
[(1, 3, {'weight': 0.5})]