-
Notifications
You must be signed in to change notification settings - Fork 108
Description
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
using Graphs
println(isgraphical([4,2,2,2])) # should print false, prints false
println(isgraphical([4,2,2,2,0])) # should print false, prints true
println(isgraphical([4,2,2,2,0]) == isgraphical([4,2,2,2])) # should definitely print true, prints false
Version information
Julia Version 1.10.4
Commit 48d4fd4843 (2024-06-04 10:41 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: 16 × AMD Ryzen 7 5800H with Radeon Graphics
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, znver3)
Threads: 1 default, 0 interactive, 1 GC (on 16 virtual cores)
Environment:
JULIA_EDITOR = code
JULIA_NUM_THREADS =
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
degs = [deg for deg in degs if deg > 0]
at the beginning of the function (e.g. after checking the sum of degrees is even, and before the sequence length is computed).