I have a distance matrix as shown below:
[A B C D....
A 0 NaN 2 3
B NaN 0 2 5
C 3 1 0 NaN
D 4 18 NaN 0
...]
To calculate centrality measures, I draw a network but it returns the same numbers for each of the centrality measures (Between, closeness, degree, etc.).
Below is my code:
(Domain: A, B, C, D, ...)
ser3 = df['Domain'].unique()
G_weighted = nx.Graph()
for x in ser3:
if(x is None):continue
for y in ser3:
ind=dist_matrix[x][y]
print(ind)
if (ind is None):continue
if (ind>0): G_weighted.add_edge(x,y,weight=ind)
nx.betweenness_centrality(G)
[Out]:
{'A': 0.0, 'B': 0.0, 'C': 0.0, 'D': 0.0, ....}
Can someone help me figure this out? Thanks a lot in advance...