Bug in LightGraphs.SimpleGraphs.random_regular_digraph

I am trying to use LightGraphs.SimpleGraphs.random_regular_digraph Method

random_regular_digraph

to create a regular random digraph. Julia version is 1.6.0 on Red Hat Linux. I am running on a single thread. I am very tired tonight but this just look plain wrong

julia> using LightGraphs

julia> adjacency_matrix(random_regular_digraph(10, 4))
10×10 SparseArrays.SparseMatrixCSC{Int64, Int64} with 40 stored entries:
⋅ 1 1 ⋅ 1 ⋅ ⋅ 1 ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ 1 ⋅ 1 1 1
⋅ ⋅ ⋅ 1 ⋅ 1 ⋅ 1 ⋅ 1
⋅ ⋅ ⋅ ⋅ ⋅ 1 1 1 1 ⋅
⋅ 1 1 ⋅ ⋅ 1 ⋅ 1 ⋅ ⋅
⋅ ⋅ ⋅ 1 ⋅ ⋅ 1 1 ⋅ 1
⋅ ⋅ 1 1 ⋅ ⋅ ⋅ 1 1 ⋅
⋅ 1 ⋅ ⋅ 1 1 ⋅ ⋅ 1 ⋅
⋅ ⋅ ⋅ 1 ⋅ 1 1 1 ⋅ ⋅
⋅ ⋅ 1 1 ⋅ ⋅ ⋅ 1 1 ⋅

Am I hallucinating or in-degrees (column sums) are messed up? I hope I am wrong as usual but in the case, this turns out to be a real bug I would love to work with a package developer to implement the state-of-the-art algorithm. I would be happy to post more references but this would be the starting point

[1511.01175] Uniform generation of random regular graphs

Oh, and in case you wonder I tried with Erdos fork of the above package as well.

julia> using Erdos

julia> adjacency_matrix(random_regular_digraph(10, 4))
10×10 SparseArrays.SparseMatrixCSC{Int64, Int64} with 40 stored entries:
⋅ 1 ⋅ 1 1 ⋅ ⋅ ⋅ 1 ⋅
⋅ ⋅ 1 ⋅ 1 ⋅ 1 1 ⋅ ⋅
⋅ 1 ⋅ ⋅ 1 1 ⋅ ⋅ 1 ⋅
⋅ ⋅ 1 ⋅ 1 ⋅ 1 ⋅ ⋅ 1
⋅ 1 ⋅ ⋅ ⋅ ⋅ 1 1 ⋅ 1
⋅ ⋅ 1 1 ⋅ ⋅ 1 ⋅ ⋅ 1
⋅ 1 1 ⋅ 1 ⋅ ⋅ 1 ⋅ ⋅
⋅ 1 1 ⋅ 1 ⋅ ⋅ ⋅ 1 ⋅
⋅ 1 ⋅ ⋅ 1 1 1 ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ 1 1 1 1 ⋅ ⋅

It appears according to one of the core developers of the JuliaLight package that the above is desired behavior of the LightGraph function. I apologize for the bug report. I failed to realize that the output of the JuliaLight function has nothing to do with the definition we use in mathematics: “A digraph is k-regular if each vertex has in-degree and out-degree k”.

https://github.com/JuliaGraphs/LightGraphs.jl/issues/1558