Skip to content

Commit

Permalink
cosmetics
Browse files Browse the repository at this point in the history
  • Loading branch information
abraunst committed Jan 31, 2024
1 parent d1cdaee commit 5e38794
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/SimpleGraphs/generators/randgraphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@ end
"maps 1:binomial(n,2) into an upper triangle of [1,n]×[1,n]"
function trianglemap(r, n)
j, i = fldmod1(r, n - 1)
i j ? Edge(i + 1, j) : Edge(n - i + 1, n - j + 1)
return i j ? Edge(i + 1, j) : Edge(n - i + 1, n - j + 1)
end

"maps 1:n*(n-1) into non-diagonal elements of [1,n]×[1,n]"
function nondiagmap(r, n)
i, j = fldmod1(r, n - 1)
Edge(i + (i j), j)
return Edge(i + (i j), j)
end

"""
Expand Down Expand Up @@ -175,9 +175,9 @@ function erdos_renyi(
m = is_directed ? n * (n - 1) : binomial(n, 2)
seq = randsubseq(rng_from_rng_or_seed(rng, seed), 1:m, p)
g = if is_directed
SimpleDiGraphFromIterator(nondiagmap(r,n) for r in seq)
SimpleDiGraphFromIterator(nondiagmap(r, n) for r in seq)
else
SimpleGraphFromIterator(trianglemap(r,n) for r in seq)
SimpleGraphFromIterator(trianglemap(r, n) for r in seq)
end
# complete to exactly n vertices
add_vertices!(g, n - nv(g))
Expand Down

0 comments on commit 5e38794

Please sign in to comment.