Skip to content

Commit faa5f50

Browse files
committed
fix all the things
1 parent 2034140 commit faa5f50

File tree

12 files changed

+312
-226
lines changed

12 files changed

+312
-226
lines changed

.travis.yml

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,14 @@
22
language: julia
33
os:
44
- linux
5-
- osx
6-
75
julia:
8-
- 1.0
9-
- 1.5
6+
- 1.3
7+
- 1
108
- nightly
11-
129
matrix:
1310
allow_failures:
1411
- julia: nightly
15-
12+
if: branch = master OR tag IS present OR type = pull_request
1613
notifications:
1714
email: false
18-
19-
# uncomment the following lines to override the default test script
20-
script:
21-
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
22-
- julia -e 'using Pkg; Pkg.clone(pwd()); Pkg.build("NetworkLayout"); Pkg.clone("LightGraphs"); Pkg.test("NetworkLayout"; coverage=true)'
23-
after_success:
24-
- julia -e 'using Pkg; cd(Pkg.dir("NetworkLayout")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(process_folder()); Codecov.submit(process_folder())'
15+
codecov: true

Manifest.toml

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
# This file is machine-generated - editing it directly is not advised
2+
3+
[[Adapt]]
4+
deps = ["LinearAlgebra"]
5+
git-tree-sha1 = "42c42f2221906892ceb765dbcb1a51deeffd86d7"
6+
uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
7+
version = "2.3.0"
8+
9+
[[Base64]]
10+
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
11+
12+
[[DataAPI]]
13+
git-tree-sha1 = "176e23402d80e7743fc26c19c681bfb11246af32"
14+
uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
15+
version = "1.3.0"
16+
17+
[[DataValueInterfaces]]
18+
git-tree-sha1 = "bfc1187b79289637fa0ef6d4436ebdfe6905cbd6"
19+
uuid = "e2d170a0-9d28-54be-80f0-106bbe20a464"
20+
version = "1.0.0"
21+
22+
[[Dates]]
23+
deps = ["Printf"]
24+
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
25+
26+
[[Distributed]]
27+
deps = ["Random", "Serialization", "Sockets"]
28+
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
29+
30+
[[EarCut_jll]]
31+
deps = ["Libdl", "Pkg"]
32+
git-tree-sha1 = "eabac56550a7d7e0be499125673fbff560eb8b20"
33+
uuid = "5ae413db-bbd1-5e63-b57d-d24a61df00f5"
34+
version = "2.1.5+0"
35+
36+
[[GeometryBasics]]
37+
deps = ["EarCut_jll", "IterTools", "LinearAlgebra", "StaticArrays", "StructArrays", "Tables"]
38+
git-tree-sha1 = "876a906eab3be990fdcbfe1e43bb3a76f4776f72"
39+
uuid = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
40+
version = "0.3.3"
41+
42+
[[InteractiveUtils]]
43+
deps = ["Markdown"]
44+
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
45+
46+
[[IterTools]]
47+
git-tree-sha1 = "05110a2ab1fc5f932622ffea2a003221f4782c18"
48+
uuid = "c8e1da08-722c-5040-9ed9-7db0dc04731e"
49+
version = "1.3.0"
50+
51+
[[IteratorInterfaceExtensions]]
52+
git-tree-sha1 = "a3f24677c21f5bbe9d2a714f95dcd58337fb2856"
53+
uuid = "82899510-4779-5014-852e-03e436cf321d"
54+
version = "1.0.0"
55+
56+
[[LibGit2]]
57+
deps = ["Printf"]
58+
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
59+
60+
[[Libdl]]
61+
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
62+
63+
[[LinearAlgebra]]
64+
deps = ["Libdl"]
65+
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
66+
67+
[[Logging]]
68+
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
69+
70+
[[Markdown]]
71+
deps = ["Base64"]
72+
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
73+
74+
[[Pkg]]
75+
deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"]
76+
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
77+
78+
[[Printf]]
79+
deps = ["Unicode"]
80+
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
81+
82+
[[REPL]]
83+
deps = ["InteractiveUtils", "Markdown", "Sockets"]
84+
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
85+
86+
[[Random]]
87+
deps = ["Serialization"]
88+
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
89+
90+
[[SHA]]
91+
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
92+
93+
[[Serialization]]
94+
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
95+
96+
[[Sockets]]
97+
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
98+
99+
[[SparseArrays]]
100+
deps = ["LinearAlgebra", "Random"]
101+
uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
102+
103+
[[StaticArrays]]
104+
deps = ["LinearAlgebra", "Random", "Statistics"]
105+
git-tree-sha1 = "016d1e1a00fabc556473b07161da3d39726ded35"
106+
uuid = "90137ffa-7385-5640-81b9-e52037218182"
107+
version = "0.12.4"
108+
109+
[[Statistics]]
110+
deps = ["LinearAlgebra", "SparseArrays"]
111+
uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
112+
113+
[[StructArrays]]
114+
deps = ["Adapt", "DataAPI", "Tables"]
115+
git-tree-sha1 = "8099ed9fb90b6e754d6ba8c6ed8670f010eadca0"
116+
uuid = "09ab397b-f2b6-538f-b94a-2f83cf4a842a"
117+
version = "0.4.4"
118+
119+
[[TableTraits]]
120+
deps = ["IteratorInterfaceExtensions"]
121+
git-tree-sha1 = "b1ad568ba658d8cbb3b892ed5380a6f3e781a81e"
122+
uuid = "3783bdb8-4a98-5b6b-af9a-565f29a5fe9c"
123+
version = "1.0.0"
124+
125+
[[Tables]]
126+
deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "LinearAlgebra", "TableTraits", "Test"]
127+
git-tree-sha1 = "24a584cf65e2cfabdadc21694fb69d2e74c82b44"
128+
uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
129+
version = "1.1.0"
130+
131+
[[Test]]
132+
deps = ["Distributed", "InteractiveUtils", "Logging", "Random"]
133+
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
134+
135+
[[UUIDs]]
136+
deps = ["Random", "SHA"]
137+
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
138+
139+
[[Unicode]]
140+
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

Project.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ uuid = "46757867-2c16-5918-afeb-47bfcb05e46a"
33
version = "0.3.0"
44

55
[deps]
6-
GeometryTypes = "4d00f742-c7ba-57c2-abde-4428a4b178cb"
6+
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
77
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
88
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
99

1010
[compat]
11-
GeometryTypes = "0.8.3"
1211
julia = "1"
1312

1413
[extras]

appveyor.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.

src/buchheim.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ positions co-ordinates of the layout
1212
"""
1313
module Buchheim
1414

15-
using GeometryTypes
15+
using GeometryBasics
1616

1717
struct Tree{A<:AbstractVector,P<:AbstractVector,F}
1818
nodes::A

src/circular.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@ julia> locs_x, locs_y = circular_layout(g)
1616
"""
1717
module Circular
1818

19-
using GeometryTypes
19+
using GeometryBasics
2020

2121
function layout(adj_matrix::AbstractMatrix)
2222
layout!(adj_matrix)
2323
end
2424

2525
function layout!(adj_matrix::AbstractMatrix)
26-
if size(adj_matrix,1) == 1
26+
if size(adj_matrix, 1) == 1
2727
return Point{2,Float64}[Point(0.0, 0.0)]
2828
else
2929
# Discard the extra angle since it matches 0 radians.
30-
θ = range(0, stop=2pi, length=size(adj_matrix,1) + 1)[1:end-1]
30+
θ = range(0, stop=2pi, length=size(adj_matrix, 1) + 1)[1:end - 1]
3131
return Point{2,Float64}[(cos(o), sin(o)) for o in θ]
3232
end
3333
end

src/sfdp.jl

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ Output :
1313
"""
1414
module SFDP
1515

16-
using GeometryTypes
16+
using GeometryBasics
1717
using LinearAlgebra: norm
1818

19-
struct Layout{M<:AbstractMatrix, P<:AbstractVector, T<:AbstractFloat}
19+
struct Layout{M <: AbstractMatrix,P <: AbstractVector,T <: AbstractFloat}
2020
adj_matrix::M
2121
positions::P
2222
tol::T
@@ -26,27 +26,27 @@ struct Layout{M<:AbstractMatrix, P<:AbstractVector, T<:AbstractFloat}
2626
end
2727

2828
function Layout(
29-
adj_matrix, PT::Type{Point{N, T}}=Point{2, Float64};
30-
startpositions=(2*rand(typ, size(adj_matrix,1)) .- 1),
29+
adj_matrix, PT::Type{Point{N,T}}=Point{2,Float64};
30+
startpositions=map(x -> 2 .* rand(PT) .- 1, 1:size(adj_matrix, 1)),
3131
tol=1.0, C=0.2, K=1.0, iterations=100
32-
) where {N, T}
32+
) where {N,T}
3333
Layout(adj_matrix, startpositions, T(tol), T(C), T(K), Int(iterations))
3434
end
3535

3636
layout(adj_matrix, dim::Int; kw_args...) = layout(adj_matrix, Point{dim,Float64}; kw_args...)
3737

3838
function layout(
39-
adj_matrix, typ::Type{Point{N, T}}=Point{2, Float64};
40-
startpositions = (2*rand(typ, size(adj_matrix,1)) .- 1),
39+
adj_matrix, PT::Type{Point{N,T}}=Point{2,Float64};
40+
startpositions=map(x -> 2 .* rand(PT) .- 1, 1:size(adj_matrix, 1)),
4141
kw_args...
42-
) where {N, T}
43-
layout!(adj_matrix,startpositions;kw_args...)
42+
) where {N,T}
43+
layout!(adj_matrix, startpositions; kw_args...)
4444
end
4545

4646
function layout!(adj_matrix,
47-
startpositions::AbstractVector{Point{N, T}};
47+
startpositions::AbstractVector{Point{N,T}};
4848
kw_args...
49-
) where {N, T}
49+
) where {N,T}
5050
network = Layout(adj_matrix, Point{N,T}; startpositions=startpositions, kw_args...)
5151
next = iterate(network)
5252
while next != nothing
@@ -60,7 +60,7 @@ end
6060
# then it could take a long time. Furthermore I'm not sure if the iterators are
6161
# the best solution in this situation
6262

63-
function iterate(network::Layout{M, P, T}) where {M, P, T}
63+
function iterate(network::Layout{M,P,T}) where {M,P,T}
6464
return network, (one(T), typemax(T), 0, true, 1, copy(network.positions))
6565
end
6666

@@ -69,20 +69,20 @@ function iterate(network::Layout, state)
6969
K, C, tol, adj_matrix = network.K, network.C, network.tol, network.adj_matrix
7070
locs = network.positions; locs0 = copy(locs)
7171
energy0 = energy; energy = zero(energy)
72-
F = eltype(locs); N = size(adj_matrix,1)
72+
F = eltype(locs); N = size(adj_matrix, 1)
7373
for i in 1:N
7474
force = F(0)
7575
for j in 1:N
7676
i == j && continue
7777
if adj_matrix[i,j] == 1
7878
# Attractive forces for adjacent nodes
79-
force += F(f_attr(locs[i],locs[j],K) * ((locs[j] - locs[i]) / norm(locs[j] - locs[i])))
79+
force += F(f_attr(locs[i], locs[j], K) .* ((locs[j] .- locs[i]) / norm(locs[j] .- locs[i])))
8080
else
8181
# Repulsive forces
82-
force += F(f_repln(locs[i],locs[j],C,K) * ((locs[j] - locs[i]) / norm(locs[j] - locs[i])))
82+
force += F(f_repln(locs[i], locs[j], C, K) .* ((locs[j] .- locs[i]) / norm(locs[j] .- locs[i])))
8383
end
8484
end
85-
locs[i] = locs[i] + step * (force / norm(force))
85+
locs[i] = locs[i] .+ step .* (force ./ norm(force))
8686
energy = energy + norm(force)^2
8787
end
8888
step, progress = update_step(step, energy, energy0, progress)
@@ -92,13 +92,13 @@ function iterate(network::Layout, state)
9292
return nothing
9393
end
9494

95-
return network, (step, energy, progress, false, iter+1, locs0)
95+
return network, (step, energy, progress, false, iter + 1, locs0)
9696
end
9797

9898
# Calculate Attractive force
99-
f_attr(a, b, K) = (norm(a-b)^2) / K
99+
f_attr(a, b, K) = (norm(a .- b).^2) ./ K
100100
# Calculate Repulsive force
101-
f_repln(a, b, C, K) = -C*(K^2) / norm(a-b)
101+
f_repln(a, b, C, K) = -C .* (K^2) / norm(a .- b)
102102

103103
function update_step(step, energy::T, energy0, progress) where {T}
104104
# cooldown step
@@ -107,7 +107,7 @@ function update_step(step, energy::T, energy0, progress) where {T}
107107
progress = progress + 1
108108
if progress >= 5
109109
progress = 0
110-
step = step/t
110+
step = step / t
111111
end
112112
else
113113
progress = 0
@@ -116,14 +116,14 @@ function update_step(step, energy::T, energy0, progress) where {T}
116116
return step, progress
117117
end
118118

119-
function dist_tolerance(locs,locs0, K, tol)
119+
function dist_tolerance(locs, locs0, K, tol)
120120
# check whether the layout is optimal
121121
for i in 1:size(locs, 1)
122-
if norm(locs[i]-locs0[i]) >= K*tol
122+
if norm(locs[i] .- locs0[i]) >= K * tol
123123
return false
124124
end
125125
end
126126
return true
127127
end
128128

129-
end #end of module
129+
end # end of module

0 commit comments

Comments
 (0)