-
Notifications
You must be signed in to change notification settings - Fork 93
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
[BUG] isgraphical
returns true for a non-graphical sequence
#400
Comments
Quick note: |
isgraphical
returns true for a non-graphical sequence
Thanks for reporting this, and sorry for the lack of reactivity in this part of the ecosystem! I'm not familiar with this function, but from what I read on the Wikipedia page of the Erdos-Gallai theorem (referenced in the docstring), that theorem only applies to simple graphs. This means self-loops should be disallowed. On the other hand, degrees equal to zero appear to be supported. Can you spot something wrong in the implementation? If so, a fix would be welcome and easy to review I think: Lines 796 to 822 in 34fd1dc
|
It would be very nice if we had a flag to allow or disallows self-loops. A while ago I tried to come up with a variant of the Erdős–Gallai for self-loops but I did not succeed so far. And I also could not find anything in the literature. Until we do so we should explicitly state in the documentation that this does not work for self-loops. |
This paper might have some solution. One difference there is that for Graphs.jl we only add |
So for a quick solution we should state in the documentation that self-loops and multiple edges are not allowed. |
See also #303 |
Description of bug, expected and actual behavior
isgraphical
returns true for a non-graphical sequence, namely[4,2,2,2,0]
. It should return false on this input.How to reproduce
Call the function
isgraphical
on input[4,2,2,2,0]
.Code demonstrating bug
Version information
Output of
]status Graphs
is[86223c79] Graphs v1.9.0
.Additional context
I at first thought the implementation allowed self-loops, in which case the sequence can be realized by (for example) the graph on vertices a,b,c,d,e with edges a-a, a-b, b-c, a-c, a-d, d-d.
However, [4,2,2,2] returns false (as it should if we disallow self-loops).
The implementation should be consistent (optionally with a flag to allow or disallow self-loops, if this is a needed feature).
If the bug is limited to cases where there is a vertex of degree zero, an easy fix would be to add the line
at the beginning of the function (e.g. after checking the sum of degrees is even, and before the sequence length is computed).
The text was updated successfully, but these errors were encountered: