You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a disconnected graph, eigenvector_centrality sometimes delivers random results.
g =SimpleGraph(6)
add_edge!.(Ref(g), 1:3, (1:3)')
add_edge!.(Ref(g), 4:6, (4:6)')
eigenvector_centrality(g)
Run this multiple times, the numbers are always different.
Strictly speaking,
Eigenvector centrality is not well-defined for disconnected graphs since the centrality scores of the individual components are independent of each other
[...] If there are several disconnected components, then the algorithm computes the eigenvector centrality individually for each component, then scales the scores according to the percentage of graph nodes in that component. The centrality score of disconnected nodes is 1/numnodes(G).
I think the randomness comes from the solver ArnoldiMethod.jl that we are using here. Even if the graph is connected we can get slightly different results between each run:
But if the graph is disconnected the eigenvalues that we get from ArnoldiMethod.jl seem to be all over the place. Its been years since I had to deal with eigenvalues and vectors so I am not sure why this is the case.
This is a general issue in JuliaGraphs that we unfortunately did not solve yet. For example we have also issues when we use spectral methods in GraphPlot.jl for disconnected graphs.
I like the idea of emulating matlabs behavior though - so perhaps for now we can just implement that and document it well.
We also should think how this functions works in case of only weakly connected directed graphs. Here is an example that shows that we also have issues in that case:
Description of bug
In a disconnected graph,
eigenvector_centrality
sometimes delivers random results.Run this multiple times, the numbers are always different.
Strictly speaking,
source on stackoverflow
Here's what Matlab does
https://de.mathworks.com/help/matlab/ref/graph.centrality.html
Potential fixes
The text was updated successfully, but these errors were encountered: