Python Forum
Centralities for Weighted Networks
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Centralities for Weighted Networks
#1
I'm making the switch from Matlab to Python for purposes of performing basic network analyses, and I'm a little confused as to how weights are factored in when computing centralities using Networkx. I apologize if this post is not formatted exactly as it should be.

Below I create a simple weighted, undirected network comprised of five nodes. I first enter the adjacency matrix and construct the graph G.

import numpy as npy
import networkx as nx
A=npy.matrix([[0,3,7,0,0],[3,0,6,0,0],[7,6,0,2,1],[0,0,2,0,4],[0,0,1,4,0]])
G=nx.from_numpy_matrix(A)
BC=nx.betweenness_centrality(G,normalized=False)
The output I obtain shows that the betweenness centralities are all zero except at node three, where it is four. This is true for the unweighted version but not for the weighted. For the weighted version, when shortest paths are defined using the original weights, the betweenness is zero except at node three, where it is 5. When shortest paths are defined using link distances (reciprocals of original weights), the centrality is 5 at node 3, 3 at node 4, and zero otherwise. All these values can be verified easily using simple hand calculations.

I've looked a the networkx documentation, and it's clear I'm missing something fundamental with regards to what option I should be adding to the nx.betweenness_centrality command so as to factor in edge weights. Any clarification would be very much appreciated.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Weighted average with multiple weights and groups amyd 0 2,110 Oct-11-2019, 10:30 AM
Last Post: amyd
  Developing larger Neural Networks Chriskelm 2 2,789 Nov-03-2018, 02:47 AM
Last Post: brighteningeyes
  Pandas dataframe: sum of exponentially weighted correlation matrices per row vvvcvvcv 1 3,261 May-29-2018, 01:09 AM
Last Post: scidam

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020