Skip to content

Commit ba8453f

Browse files
authored
Merge pull request #23 from JuliaGraphs/sd/fixup_no_appveyor
fixup travis, remove appveyor, fix depwarns, move to GeometryBasics, use JuliaFormatter
2 parents 728e58e + d698d19 commit ba8453f

15 files changed

+252
-314
lines changed

.JuliaFormatter.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
always_for_in = true
2+
always_use_return = true
3+
import_to_using = true
4+
margin = 110
5+
pipe_to_function_call = true
6+
remove_extra_newlines = true
7+
short_to_long_function_def = true
8+
style = "yas"
9+
whitespace_in_kwargs = false
10+
whitespace_ops_in_indices = true
11+
whitespace_typedefs = false

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
*.jl.cov
22
*.jl.*.cov
33
*.jl.mem
4+
Manifest.toml

.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-
- 0.7
9-
- 1.0
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

Project.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name = "NetworkLayout"
2+
uuid = "46757867-2c16-5918-afeb-47bfcb05e46a"
3+
version = "0.3.0"
4+
5+
[deps]
6+
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
7+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
8+
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
9+
10+
[compat]
11+
julia = "1"
12+
13+
[extras]
14+
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
15+
GeometryTypes = "4d00f742-c7ba-57c2-abde-4428a4b178cb"
16+
LightGraphs = "093fc24a-ae57-5d10-9952-331d41423f4d"
17+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
18+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
19+
20+
[targets]
21+
test = ["LightGraphs", "Test", "DelimitedFiles", "GeometryTypes"]

REQUIRE

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

appveyor.yml

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

src/buchheim.jl

Lines changed: 20 additions & 19 deletions
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
@@ -41,7 +41,7 @@ function Tree(tree::AbstractVector, nodesize)
4141
end
4242

4343
function layout(t::AbstractVector; nodesize=ones(length(t)))
44-
layout!(t, nodesize)
44+
return layout!(t, nodesize)
4545
end
4646

4747
function layout!(t::AbstractVector, nodesize)
@@ -54,7 +54,7 @@ end
5454
function parent(v, t::Tree)
5555
tree = t.nodes
5656
for i in 1:length(tree)
57-
y = findall(x -> (x==v), tree[i])
57+
y = findall(x -> (x == v), tree[i])
5858
if length(y) != 0
5959
return i
6060
end
@@ -67,28 +67,28 @@ function first_walk(v, t::Tree)
6767
mod = t.mod
6868
tree = t.nodes
6969
nodesize = t.nodesize
70-
p = parent(v,t)
70+
p = parent(v, t)
7171
if p != nothing
72-
index = findall(x -> (x==v), tree[p])[1]
72+
index = findall(x -> (x == v), tree[p])[1]
7373
else
7474
index = 1
7575
end
7676
if length(tree[v]) == 0
7777
if v != tree[p][1]
78-
prelim[v] = prelim[tree[p][index-1]] + (nodesize[tree[p][index-1]])
78+
prelim[v] = prelim[tree[p][index - 1]] + (nodesize[tree[p][index - 1]])
7979
else
80-
prelim[v] = 0
80+
prelim[v] = 0
8181
end
8282
else
8383
defaultAncestor = tree[v][1]
8484
for w in tree[v]
85-
first_walk(w,t)
85+
first_walk(w, t)
8686
defaultAncestor = apportion(w, defaultAncestor, t)
8787
end
8888
execute_shifts(v, t)
8989
midpoint = (prelim[tree[v][1]] + prelim[tree[v][end]]) / 2
9090
if index > 1
91-
w = tree[p][index-1]
91+
w = tree[p][index - 1]
9292
prelim[v] = prelim[w] + (nodesize[w] + 1.0)
9393
mod[v] = prelim[v] - midpoint
9494
else
@@ -106,28 +106,29 @@ function apportion(v::T, defaultAncestor::T, t::Tree) where {T}
106106
p = parent(v, t)
107107
nodesize = t.nodesize
108108
if p != nothing
109-
index = findall(x-> (x==v), tree[p])[1]
109+
index = findall(x -> (x == v), tree[p])[1]
110110
else
111111
index = 1
112112
end
113113
if index > 1
114-
w = tree[p][index-1]
114+
w = tree[p][index - 1]
115115
v_in_right = v_out_right = v
116116
v_in_left = w
117117
v_out_left = tree[parent(v_in_right, t)][1]
118118
s_in_right = mod[v_in_right]
119119
s_out_right = mod[v_out_right]
120120
s_in_left = mod[v_in_left]
121121
s_out_left = mod[v_out_left]
122-
while next_right(v_in_left, t)!=0 && next_left(v_in_right, t)!=0
122+
while next_right(v_in_left, t) != 0 && next_left(v_in_right, t) != 0
123123
v_in_left = next_right(v_in_left, t)
124124
v_in_right = next_left(v_in_right, t)
125125
v_out_left = next_left(v_out_left, t)
126126
v_out_right = next_right(v_out_right, t)
127127
ancestor[v_out_right] = v
128-
shift = (prelim[v_in_left] + s_in_left) - (prelim[v_in_right] + s_in_right) + (nodesize[v_in_left])
128+
shift = (prelim[v_in_left] + s_in_left) - (prelim[v_in_right] + s_in_right) +
129+
(nodesize[v_in_left])
129130
if shift > 0
130-
move_subtree(find_ancestor(v_in_left, v, defaultAncestor,t), v,shift, t)
131+
move_subtree(find_ancestor(v_in_left, v, defaultAncestor, t), v, shift, t)
131132
s_in_right += shift
132133
s_out_right += shift
133134
end
@@ -140,7 +141,7 @@ function apportion(v::T, defaultAncestor::T, t::Tree) where {T}
140141
thread[v_out_right] = next_right(v_in_left, t)
141142
mod[v_out_right] += s_in_left - s_out_right
142143
else
143-
if next_left(v_in_right,t) != 0 && next_left(v_out_left,t) == 0
144+
if next_left(v_in_right, t) != 0 && next_left(v_out_left, t) == 0
144145
thread[v_out_left] = next_left(v_in_right, t)
145146
mod[v_out_left] += s_in_right - s_out_left
146147
defaultAncestor = v
@@ -152,7 +153,7 @@ end
152153

153154
function number(v, t::Tree)
154155
p = parent(v, t)
155-
index = findall(x -> (x==v), t.nodes[p])[1]
156+
index = findall(x -> (x == v), t.nodes[p])[1]
156157
return index
157158
end
158159

@@ -169,22 +170,22 @@ function move_subtree(w_left::T, w_right::T, shift::Float64, t::Tree) where {T}
169170
shifttree[w_right] += shift
170171
change[w_left] += shift / subtrees
171172
prelim[w_right] += shift
172-
mod[w_right] += shift
173+
return mod[w_right] += shift
173174
end
174175

175176
function second_walk(v, m::Float64, depth::Float64, t::Tree)
176177
prelim = t.prelim
177178
mod = t.mod
178179
positions = t.positions
179180
nodesize = t.nodesize
180-
positions[v] = Point(prelim[v]+m, -depth)
181+
positions[v] = Point(prelim[v] + m, -depth)
181182
if length(t.nodes[v]) != 0
182183
maxdist = maximum([nodesize[i] for i in t.nodes[v]])
183184
else
184185
maxdist = 0
185186
end
186187
for w in t.nodes[v]
187-
second_walk(w, m+mod[v], Float64(depth + 1 + maxdist), t)
188+
second_walk(w, m + mod[v], Float64(depth + 1 + maxdist), t)
188189
end
189190
end
190191

src/circular.jl

Lines changed: 4 additions & 4 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)
22-
layout!(adj_matrix)
22+
return 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

0 commit comments

Comments
 (0)