1
$\begingroup$

I am using the following code to try implement eigen-vector centrality for a weighted graph G. The nodes represent search terms and the is an edge from node A to node B if someone searches for A and then B. The edge weight is the number of times this happens i.e. the number of time someone searches for A and then searches for B.

import networkx as nx

G = nx.DiGraph()
G.add_node(1)
G.add_node(2)


G.add_edge(1,2, weight = 100)
G.add_edge(2,1, weight = 1)


centrality = nx.eigenvector_centrality(G,weight = 'weights', max_iter= 1000) 
print(centrality)

However I am getting identical scores for each node, the output of the above program is: {1: 0.7071067811865476, 2: 0.7071067811865476}

I suspect that the algorithm is not taking the weights into account, otherwise the scores would be different (?)

How can I can I make the program look at weights?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.