@@ -23,12 +23,17 @@ struct Layout{M<:AbstractMatrix,P<:AbstractVector,T<:AbstractFloat}
23
23
C:: T
24
24
K:: T
25
25
iterations:: Int
26
+ fixed:: BitVector
26
27
end
27
28
28
29
function Layout (adj_matrix, PT:: Type{Point{N,T}} = Point{2 ,Float64};
29
- startpositions= map (x -> 2 .* rand (PT) .- 1 , 1 : size (adj_matrix, 1 )), tol= 1.0 , C= 0.2 , K= 1.0 ,
30
- iterations= 100 ) where {N,T}
31
- return Layout (adj_matrix, startpositions, T (tol), T (C), T (K), Int (iterations))
30
+ startpositions= map (x -> 2 .* rand (PT) .- 1 , 1 : size (adj_matrix, 1 )),
31
+ tol= 1.0 ,
32
+ C= 0.2 ,
33
+ K= 1.0 ,
34
+ iterations= 100 ,
35
+ fixed = falses (length (startpositions))) where {N,T}
36
+ return Layout (adj_matrix, startpositions, T (tol), T (C), T (K), Int (iterations), fixed)
32
37
end
33
38
34
39
layout (adj_matrix, dim:: Int ; kw_args... ) = layout (adj_matrix, Point{dim,Float64}; kw_args... )
@@ -78,7 +83,9 @@ function iterate(network::Layout, state)
78
83
((locs[j] .- locs[i]) / norm (locs[j] .- locs[i])))
79
84
end
80
85
end
81
- locs[i] = locs[i] .+ step .* (force ./ norm (force))
86
+ if ! network. fixed[i]
87
+ locs[i] = locs[i] .+ step .* (force ./ norm (force))
88
+ end
82
89
energy = energy + norm (force)^ 2
83
90
end
84
91
step, progress = update_step (step, energy, energy0, progress)
0 commit comments