Skip to content

Commit 8c45251

Browse files
adding fixed locations to sfdp
1 parent 00491f9 commit 8c45251

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/sfdp.jl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,17 @@ struct Layout{M<:AbstractMatrix,P<:AbstractVector,T<:AbstractFloat}
2323
C::T
2424
K::T
2525
iterations::Int
26+
fixed::BitVector
2627
end
2728

2829
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)
3237
end
3338

3439
layout(adj_matrix, dim::Int; kw_args...) = layout(adj_matrix, Point{dim,Float64}; kw_args...)
@@ -78,7 +83,9 @@ function iterate(network::Layout, state)
7883
((locs[j] .- locs[i]) / norm(locs[j] .- locs[i])))
7984
end
8085
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
8289
energy = energy + norm(force)^2
8390
end
8491
step, progress = update_step(step, energy, energy0, progress)

0 commit comments

Comments
 (0)