Reputation: 616
I have a dataframe, which is a weighted edge list:
from A to B weight
1 2 1
3 5 1
1 4 1
4 1 3
1 3 2
6 2 1
I am new to the concept of networks, nodes, centrality score etc
I am trying to calculate centrality score from this weighted edge list.
Anything can help. A solution, link to somewhere I can refer to, or just any comments. Thanks!
Upvotes: 0
Views: 315
Reputation: 15738
A lot of times the best available documentation on networkx is reading its sources. Here is a not-so-obvious example:
# df = pd.DataFrame({'from A': [1,3,1,4,1,6], 'to B': [2,5,4,1,3,2], 'weight': [1,1,1,3,2,1]})
graph = nx.from_pandas_edgelist(df, 'from A', 'to B', ['weight'], create_using=nx.DiGraph)
graph.degree(weight='weight') # DiDegreeView({1: 7, 2: 2, 3: 3, 5: 1, 4: 4, 6: 1})
Upvotes: 1