weighted_projected_graph(B, nodes, ratio=False)
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
. 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.
No attempt is made to verify that the input graph B is bipartite, or that the input nodes are distinct. However, if the length of the input nodes is greater than or equal to the nodes in the graph B, an exception is raised. If the nodes are not distinct but don't raise this error, the output weights will be incorrect. The graph and node properties are (shallow) copied to the projected graph.
See bipartite documentation <networkx.algorithms.bipartite>
for further details on how bipartite graphs are handled in NetworkX.
The input graph should be bipartite.
Distinct nodes to project onto (the "bottom" nodes).
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.
A graph that is the projection onto the given nodes.
Returns a weighted projection of B onto one of its node sets.
>>> 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)See :
... list(G.edges(data=True)) [(1, 3, {'weight': 0.5})]
The following pages refer to to this document either explicitly or contain code examples using this.
networkx.algorithms.bipartite.projection.collaboration_weighted_projected_graph
networkx.algorithms.bipartite.projection.projected_graph
networkx.algorithms.bipartite.projection.overlap_weighted_projected_graph
networkx.algorithms.bipartite.projection.generic_weighted_projected_graph
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them