Hi everyone,
I am working on a directed graph with some negative weights and self loops. As such, I figured that to calculate betweenness centrality I'd have to use the absolute value of the weights instead of the raw weights, because otherwise the graph has some paths of infinitely short length... but instead, nx doesn't seem to mind:
try:
nx.shortest_path(G, weight = 'weight')
print 'Shortest Path works ok!'
# Throws a Value Error
except ValueError:
print 'Error in Shortest Path'
try:
nx.betweenness_centrality(G, weight = 'weight')
print 'BC works ok!'
except ValueError:
print 'Error in BC'
# Works ?? How?
Gives:
Error in Shortest Path
BC works ok!
How is the shortest path algorithm actually working with negative cycles? I tried digging into the bc algorithm, and it looks like it calls the _single_source_dijkstra_path_basic routine internally. Is this intended?
Federico