xgi
xgi copied to clipboard
wrong degree count with singleton
Running
HH = xgi.Hypergraph([{1, 2, 3}, {4}, {5, 6}, {6, 7, 8}])
xgi.degree_counts(HH)
outputs [0, 7, 1]
.
It is even our test: https://github.com/ComplexGroupInteractions/xgi/blob/c262f406cf13e3d51e7b40e5534fbfcca223caff/tests/classes/test_function.py#L58).
But node 4 does not have any neighbour, so degree 0 should have count 1: the output should be [1, 6, 1]
.
I think the rationale is that 4 belongs to one (singleton) edge. So in a way, it is correct. The fix would be to add a parameter "ignore_singletons" as is done elsewhere in the codebase.
On Wed, Oct 5, 2022, 4:55 PM Maxime Lucas @.***> wrote:
Running
HH = xgi.Hypergraph([{1, 2, 3}, {4}, {5, 6}, {6, 7, 8}])xgi.degree_counts(HH)
outputs [0, 7, 1].
It is even our test: https://github.com/ComplexGroupInteractions/xgi/blob/c262f406cf13e3d51e7b40e5534fbfcca223caff/tests/classes/test_function.py#L58 ).
But node 4 does not have any neighbour, so degree 0 should have count 1: the output should be [1, 6, 1].
— Reply to this email directly, view it on GitHub https://github.com/ComplexGroupInteractions/xgi/issues/190, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAILYAARUKLWDY4CWW5UUK3WBWJGXANCNFSM6AAAAAAQ5U76IA . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Sure I agree that 4 is a singleton edge here. But what would you say the degree of node 4 is here?
I would say 0 because node 4 has no neighbour (not connected by any node by an edge). Or would you say it's 1 because the singleton edge 4 is a self-loop for node 4 to node 4? It thought that would have been encoded as an edge (4,4) - but now that I think of it, that cannot exist we have edges as sets now. Still would feel weird to have a self-loop represented as singleton edge no?
It comes down to a matter of semantics/perspective. Is the degree the number of neighboring nodes? If so, do you count repetitions (when a neighbor appears in many different edges)? Or is the degree defined as the number of edges a node belongs to?
Since we are using the bipartite representation, I'd say the degree of a node in the hypergraph should just be the degree of the node in the bipartite representation, and in this case it is 1 because it belongs to exactly one hyperedge, which just happens to be a singleton.
But that's just my opinion and I'm happy to be convinced otherwise :)
Ok I see where this is coming from now, thanks. Might just touch on this in next meeting to make sure it makes sense for everyone, and maybe specify in docs? This particular case of the singleton still feels weird to me even though I understand the bipartite reason 😅
Agreed, let's put it in the agenda.
I can totally share Max's doubts, but I also completely agree with the "clean" definition by Leo of degree as given by the bipartite. I would say that the only thing really needed at this point is to stress this example as much as possible in the documentation ;)
Agreed, at this point we should just pick one and stick with it.
(Though, if I may add one more data point: in graphs with self-loops, usually a node's degree is increased by 2 if it has a self-loop...)
If I remember correctly, we decided to simply add an explanation in the docstring for this, right?
Yes!