Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# NetworkLayout Release Notes

## v0.4.11 Changelog
- Fixes two bugs in the iteration scheme:
- The layout iterator returned the second-to-last layout; now it returns the final positions after full iteration.
- Iterative layouts computed `iterations` layouts, including the initial guess. Now `iterations` describes the number of actual *iterations*, and the layout iterator returns at most `iterations + 1` layouts.
10 changes: 3 additions & 7 deletions src/NetworkLayout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,9 @@ end

function layout(alg::IterativeLayout, adj_matrix::AbstractMatrix)
assertsquare(adj_matrix)
iter = LayoutIterator(alg, adj_matrix)
next = Base.iterate(iter)
pos = next[1]
while next !== nothing
(item, state) = next
next = Base.iterate(iter, state)
pos = next !== nothing ? item : pos
local pos
for item in LayoutIterator(alg, adj_matrix)
pos = item
end
return pos
end
Expand Down
2 changes: 1 addition & 1 deletion src/sfdp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function Base.iterate(iter::LayoutIterator{<:SFDP}, state)
K, C, tol = algo.K, algo.C, algo.tol

# stop if stopflag (tol reached) or nr of iterations reached
if iter >= algo.iterations || stopflag
if iter > algo.iterations || stopflag
return nothing
end

Expand Down
2 changes: 1 addition & 1 deletion src/spring.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ end
function Base.iterate(iter::LayoutIterator{<:Spring}, state)
algo, adj_matrix = iter.algorithm, iter.adj_matrix
iteration, old_pos, pin, rng = state
iteration >= algo.iterations && return nothing
iteration > algo.iterations && return nothing

# The optimal distance bewteen vertices
N = size(adj_matrix, 1)
Expand Down
2 changes: 1 addition & 1 deletion src/stress.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ function Base.iterate(iter::LayoutIterator{<:Stress{Dim,Ptype}}, state) where {D
algo, δ = iter.algorithm, iter.adj_matrix
i, oldstress, oldpos, weights, distances, pinvLw, maxiter, pin, stopflag = state

if i >= maxiter || stopflag
if i > maxiter || stopflag
return nothing
end

Expand Down
17 changes: 10 additions & 7 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ jagmesh_adj = jagmesh()
for p in it
push!(vec, p)
end
@test length(vec) == l
@test length(unique!(vec)) == l
@test length(vec) == l + 1
@test it.algorithm(adj_matrix) == last(vec)
@test length(unique!(vec)) == l + 1
end
end

Expand Down Expand Up @@ -103,8 +104,9 @@ jagmesh_adj = jagmesh()
for p in it
push!(vec, p)
end
@test length(vec) == l
@test length(unique!(vec)) == l
@test length(vec) == l + 1
@test it.algorithm(adj_matrix) == last(vec)
@test length(unique!(vec)) == l + 1
end
end

Expand Down Expand Up @@ -211,8 +213,9 @@ jagmesh_adj = jagmesh()
for p in it
push!(vec, p)
end
@test length(vec) == l
@test length(unique!(vec)) == l
@test length(vec) == l + 1
@test it.algorithm(adj_matrix) == last(vec)
@test length(unique!(vec)) == l + 1
end
end

Expand Down Expand Up @@ -472,7 +475,7 @@ jagmesh_adj = jagmesh()
positions :: Vector{Point{Dim, Ptype}}
end
NetworkLayout.layout(algo::Manual, ::AbstractMatrix) = copy(algo.positions)

g = Graph(2); add_edge!(g, 1, 2)
pos = Align(Manual([Point2f(1, 2), Point2f(2, 3)]), 0.0)(g)
@test all(r->abs(r[2])<1e-12, pos)
Expand Down
Loading