Closed ppunosevac closed 3 years ago
This is expected behavior. From the docstring:
Optional Arguments
––––––––––––––––––––
• dir=:out: the direction of the edges for degree parameter.
Definition: "A digraph is k-regular if each vertex has in-degree and out-degree k". random_regular_digraph
function generates a digraph with prescribed out-degree dir=:out
or prescribed in-degree dir:=in
. 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.
Description of bug
adjacency_matrix(random_regular_digraph(10, 4))
doesn't produce a regular digraph. in-degrees are messed up.How to reproduce
using LightGraphs
adjacency_matrix(random_regular_digraph(10, 4))
Expected behavior I expect row sums and column sums to be the constant equal to four.
Actual behavior
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 ⋅
Code demonstrating bug
using LightGraphs
adjacency_matrix(random_regular_digraph(10, 4))
julia> versioninfo() Julia Version 1.6.0 Commit f9720dc2eb (2021-03-24 12:55 UTC) Platform Info: OS: Linux (x86_64-pc-linux-gnu) CPU: Intel(R) Xeon(R) CPU E5-2620 v4 @ 2.10GHz WORD_SIZE: 64 LIBM: libopenlibm LLVM: libLLVM-11.0.1 (ORCJIT, broadwell)
(@v1.6) pkg> status LightGraphs Status
~/.julia/environments/v1.6/Project.toml[093fc24a] LightGraphs v1.3.5
I hope I am wrong. If this turns out to be a real bug I would love to help implement the state of the art
https://arxiv.org/abs/1511.01175