Centrality measures NetworkX on a bipartite network

170 views
Skip to first unread message

Srinidhi Vasudevan

unread,
Oct 21, 2016, 10:00:50 AM10/21/16
to networkx-discuss

I am a naive Python programmer and using it for my network data, so pardon me if this sounds silly. I have a two mode network with individuals and organisations. I have this as an edge list saved as a CSV file that I import to python. I have managed to read the CSV, project the graph into a bipartite network and export the file to gephi. After doing this, I am calculating the centrality (degree, eigenvector, closeness and betweenness) for my one mode projected and weighted graph. My code is as follows:

organisation_nodes, individual_nodes = bipartite.sets(B)
individual_nodes = set(n for n,d in B.nodes(data=True) if d['bipartite']==1)
organisation_nodes = set(B) - individual_nodes
organisation_graph = bipartite.weighted_projected_graph(B, organisation_nodes)org = bipartite.projected_graph(B, organisation_nodes)
print nx.info(org)
#degree centrality
deg_cent = nx.degree(org)
between_cent = nx.betweenness_centrality(org)
print between_cent
eigenvect_cent = nx.eigenvector_centrality(org)
print eigenvect_cent
close_cent = nx.closeness_centrality(org)

I visualised the graphml file that I got from the projected network onto Gephi and calculated the centrality measures there. However, there is a discrepancy in the centrality values calculated by Gephi and NetworkX. Only the density and the degree centrality values match. Is there something wrong with my code? If not, why the difference? Any help would be greatly appreciated, Thanks

Daniel Schult

unread,
Oct 21, 2016, 11:12:49 AM10/21/16
to networkx...@googlegroups.com
Most of our functions for centrality measures have formulas for what they compute. See https://networkx.github.io/documentation/development/reference/algorithms.centrality.html
and the links from there.

It is quite likely that you are doing nothing wrong, but that the definitions used differ slightly between gephi and networkx. I suggest that you compare formulas for the two packages and see how they differ. Perhaps try a simple example (5 node star?) to make sure you understand what each is doing.

If you have questions about what NetworkX does, ask again. :)


--
You received this message because you are subscribed to the Google Groups "networkx-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to networkx-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to networkx-discuss@googlegroups.com.
Visit this group at https://groups.google.com/group/networkx-discuss.
For more options, visit https://groups.google.com/d/optout.

Srinidhi Vasudevan

unread,
Nov 7, 2016, 1:49:10 PM11/7/16
to networkx-discuss
Thank you Daniel, Looks like closeness was calculated differently. I do have an issue though with Eigenvector centrality. Have calculated it on NetworkX and UCINET and the ranking of the nodes as well as the values differ (the algorithm remains the same and the values aren't normalised). Is this something normal?

Regards
Srinidhi
To unsubscribe from this group and stop receiving emails from it, send an email to networkx-discu...@googlegroups.com.
To post to this group, send email to networkx...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages