Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong degree count with singleton #190

Closed
maximelucas opened this issue Oct 5, 2022 · 9 comments · Fixed by #329
Closed

wrong degree count with singleton #190

maximelucas opened this issue Oct 5, 2022 · 9 comments · Fixed by #329

Comments

@maximelucas
Copy link
Collaborator

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].

@leotrs
Copy link
Collaborator

leotrs commented Oct 11, 2022 via email

@maximelucas
Copy link
Collaborator Author

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?

@leotrs
Copy link
Collaborator

leotrs commented Oct 24, 2022

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 :)

@maximelucas
Copy link
Collaborator Author

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 😅

@leotrs
Copy link
Collaborator

leotrs commented Oct 27, 2022

Agreed, let's put it in the agenda.

@iaciac
Copy link
Collaborator

iaciac commented Nov 3, 2022

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 ;)

@leotrs
Copy link
Collaborator

leotrs commented Nov 3, 2022

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...)

@maximelucas
Copy link
Collaborator Author

If I remember correctly, we decided to simply add an explanation in the docstring for this, right?

@leotrs
Copy link
Collaborator

leotrs commented Apr 5, 2023

Yes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants