This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.
#!/usr/bin/env python """ 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 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('%d %s' % (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('%d %s' % (W.degree(w,weight='weight'),w))