-
Notifications
You must be signed in to change notification settings - Fork 114
Open
Labels
bugSomething isn't workingSomething isn't workinghelp wantedExtra attention is neededExtra attention is needed
Description
Description of bug
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
Here's what Matlab does
[...] 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).
https://de.mathworks.com/help/matlab/ref/graph.centrality.html
Potential fixes
- add a warning to the documentation
- check if a graph is connected and warn/error if it isn't
- emulate Matlab's behavior
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinghelp wantedExtra attention is neededExtra attention is needed