Mercurial > repos > shellac > sam_consensus_v3
view env/share/doc/networkx-2.5/examples/algorithms/plot_davis_club.py @ 0:4f3585e2f14b draft default tip
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author | shellac |
---|---|
date | Mon, 22 Mar 2021 18:12:50 +0000 |
parents | |
children |
line wrap: on
line source
""" ========== Davis Club ========== Davis Southern Club Women Shows how to make unipartite projections of the graph and compute the properties of those graphs. These data were collected by Davis et al. in the 1930s. They represent observed attendance at 14 social events by 18 Southern women. The graph is bipartite (clubs, women). """ import matplotlib.pyplot as plt import networkx as nx import networkx.algorithms.bipartite as bipartite G = nx.davis_southern_women_graph() women = G.graph["top"] clubs = G.graph["bottom"] print("Biadjacency matrix") print(bipartite.biadjacency_matrix(G, women, clubs)) # project bipartite graph onto women nodes W = bipartite.projected_graph(G, women) print() print("#Friends, Member") for w in women: print(f"{W.degree(w)} {w}") # project bipartite graph onto women nodes keeping number of co-occurence # the degree computed is weighted and counts the total number of shared contacts W = bipartite.weighted_projected_graph(G, women) print() print("#Friend meetings, Member") for w in women: print(f"{W.degree(w, weight='weight')} {w}") nx.draw(G) plt.show()