Skip to content

Commit 609c6e6

Browse files
Apply suggestions from code review
Co-authored-by: Simon Schölly <[email protected]>
1 parent 1dacc67 commit 609c6e6

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

src/NetworkLayout.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ export LayoutIterator, layout
1010
"""
1111
AbstractLayout{Dim,Ptype}
1212
13-
Abstract supertype for all layouts. Each layout `Algorithm <: AbstractLayout` needs to
13+
Abstract supertype for all layouts. Each layout `Layout <: AbstractLayout` needs to
1414
implement
1515
16-
layout(algo::Algorithm, adj_matrix)::Vector{Point{Dim,Ptype}}
16+
layout(::Layout, adj_matrix)::Vector{Point{Dim,Ptype}}
1717
1818
which takes the adjacency matrix representation of a network and returns a list of
19-
node positions. Each `Algorithm` object holds all of the necessary parameters.
19+
node positions. Each `Layout` object holds all of the necessary parameters.
2020
21-
By implementing `layout` the algorithm also inherits the function-like property
21+
By implementing `layout` the Layout also inherits the function-like property
2222
23-
Algorithm(; kwargs...)(adj_matrix) -> node_positions
23+
Layout(; kwargs...)(adj_matrix) -> node_positions
2424
"""
2525
abstract type AbstractLayout{Dim,Ptype} end
2626

src/buchheim.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function adj_mat_to_list(M::AbstractMatrix)
5858
N = size(M, 1)
5959
list = Vector{Vector{Int}}(undef, N)
6060
for i in 1:N
61-
list[i] = findall(x -> !iszero(x), view(M, i, :))
61+
list[i] = findall(!iszero, view(M, i, :))
6262
end
6363
return list
6464
end

src/squaregrid.jl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ function layout(algo::SquareGrid{Ptype}, adj_matrix::AbstractMatrix) where {Ptyp
3434
M = N + length(algo.skip)
3535

3636
if algo.cols === :auto
37-
cols = 0
38-
while (cols^2 < M)
39-
cols += 1
40-
end
37+
cols = (M == 0) ? 0 : (isqrt(M - 1) + 1)
4138
else
4239
cols = algo.cols
4340
end

0 commit comments

Comments
 (0)