J'ai créé un network à partir d'un fichier csv en utilisant :
1 2
| adj_mat = np.loadtxt("outputsnet/output.csv",delimiter=',',skiprows=0)
net = nx.from_numpy_matrix(adj_mat, create_using=nx.DiGraph()) |
Et quand je tape:
1 2
| w=net.edges(data=True)
print w |
j'obtiens:
[(51, 92, {'weight': 589.0}), (51, 95, {'weight': 579.0}), (53, 82, {'weight': 644.0}), (56, 83, {'weight': 644.0}), (58, 93, {'weight': 589.0}), (59, 84, {'weight': 644.0}), (62, 96, {'weight': 579.0}), (64, 97, {'weight': 579.0}), (65, 89, {'weight': 599.0}), (65, 98, {'weight': 579.0}), (66, 99, {'weight': 579.0})]
Mon problème est que lorsque je veux calculer le eigenvector centrality du réseau en écrivant:
1 2
| centrality = nx.eigenvector_centrality(net,weight='weight')
print(['%s %0.2f'%(node,centrality[node]) for node in centrality]) |
j'obtiens tous les poids à 0:
['64 0.00', '65 0.00', '66 0.00', '99 0.00', '51 0.00', '97 0.00', '96 0.00', '98 0.00', '82 0.00', '83 0.00', '84 0.00', '53 0.00', '56 0.00', '89 0.00', '58 0.00', '59 0.00', '92 0.00', '93 0.00', '62 0.00', '95 0.00']
Je n'ai pas compris pourquoi les poids que j'ai passés ne sont pas considérés.
Quelqu'un pourrait-il m'aider la-dessus ?
Partager