Skip to content

Commit 92dcc35

Browse files
committed
Remove splats and slurps
1 parent d85cb80 commit 92dcc35

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/lines.jl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ function graphline(g::AbstractGraph{T}, locs_x, locs_y, nodesize::Real) where {T
7676
end
7777

7878
function graphcurve(g::AbstractGraph{T}, locs_x, locs_y, nodesize::Vector{<:Real}, arrowlength, angleoffset, outangle=pi/5) where {T<:Integer}
79-
curves = Vector{Vector{Tuple{Float64,Float64}}}(undef, ne(g))
79+
curves = Matrix{Tuple{Float64,Float64}}(undef, ne(g), 4)
8080
arrows = Array{Vector{Tuple{Float64,Float64}}}(undef, ne(g))
8181
for (e_idx, e) in enumerate(edges(g))
8282
i = src(e)
@@ -95,16 +95,16 @@ function graphcurve(g::AbstractGraph{T}, locs_x, locs_y, nodesize::Vector{<:Real
9595
d = 2 * π * nodesize[i]
9696
end
9797

98-
curves[e_idx] = curveedge(startx, starty, endx, endy, θ, outangle, d)
98+
curves[e_idx, :] = curveedge(startx, starty, endx, endy, θ, outangle, d)
9999

100100
arr1, arr2 = arrowcoords-outangle, endx, endy, arrowlength, angleoffset)
101101
arrows[e_idx] = [arr1, (endx, endy), arr2]
102102
end
103-
return vcat.(curves...), arrows
103+
return curves, arrows
104104
end
105105

106106
function graphcurve(g, locs_x, locs_y, nodesize::Real, arrowlength, angleoffset, outangle=pi/5)
107-
curves = Vector{Vector{Tuple{Float64,Float64}}}(undef, ne(g))
107+
curves = Matrix{Tuple{Float64,Float64}}(undef, ne(g), 4)
108108
arrows = Array{Vector{Tuple{Float64,Float64}}}(undef, ne(g))
109109
for (e_idx, e) in enumerate(edges(g))
110110
i = src(e)
@@ -123,16 +123,16 @@ function graphcurve(g, locs_x, locs_y, nodesize::Real, arrowlength, angleoffset,
123123
d = 2 * π * nodesize
124124
end
125125

126-
curves[e_idx] = curveedge(startx, starty, endx, endy, θ, outangle, d)
126+
curves[e_idx, :] = curveedge(startx, starty, endx, endy, θ, outangle, d)
127127

128128
arr1, arr2 = arrowcoords-outangle, endx, endy, arrowlength, angleoffset)
129129
arrows[e_idx] = [arr1, (endx, endy), arr2]
130130
end
131-
return vcat.(curves...), arrows
131+
return curves, arrows
132132
end
133133

134134
function graphcurve(g, locs_x, locs_y, nodesize::Real, outangle)
135-
curves = Vector{Vector{Tuple{Float64,Float64}}}(undef, ne(g))
135+
curves = Matrix{Tuple{Float64,Float64}}(undef, ne(g), 4)
136136
for (e_idx, e) in enumerate(edges(g))
137137
i = src(e)
138138
j = dst(e)
@@ -150,13 +150,13 @@ function graphcurve(g, locs_x, locs_y, nodesize::Real, outangle)
150150
d = 2 * π * nodesize
151151
end
152152

153-
curves[e_idx] = curveedge(startx, starty, endx, endy, θ, outangle, d)
153+
curves[e_idx, :] = curveedge(startx, starty, endx, endy, θ, outangle, d)
154154
end
155-
return vcat.(curves...)
155+
return curves
156156
end
157157

158158
function graphcurve(g::AbstractGraph{T}, locs_x, locs_y, nodesize::Vector{<:Real}, outangle) where {T<:Integer}
159-
curves = Vector{Vector{Tuple{Float64,Float64}}}(undef, ne(g))
159+
curves = Matrix{Tuple{Float64,Float64}}(undef, ne(g), 4)
160160
for (e_idx, e) in enumerate(edges(g))
161161
i = src(e)
162162
j = dst(e)
@@ -174,9 +174,9 @@ function graphcurve(g::AbstractGraph{T}, locs_x, locs_y, nodesize::Vector{<:Real
174174
d = 2 * π * nodesize[i]
175175
end
176176

177-
curves[e_idx] = curveedge(startx, starty, endx, endy, θ, outangle, d)
177+
curves[e_idx, :] = curveedge(startx, starty, endx, endy, θ, outangle, d)
178178
end
179-
return vcat.(curves...)
179+
return curves
180180
end
181181

182182
# this function is copy from [IainNZ](https://github.com/IainNZ)'s [GraphLayout.jl](https://github.com/IainNZ/GraphLayout.jl)
@@ -199,5 +199,5 @@ function curveedge(x1, y1, x2, y2, θ, outangle, d; k=0.5)
199199
xc2 = x2 + r * cos+ π - outangle)
200200
yc2 = y2 + r * sin+ π - outangle)
201201

202-
return [(x1,y1), (xc1, yc1), (xc2, yc2), (x2, y2)]
202+
return [(x1,y1) (xc1, yc1) (xc2, yc2) (x2, y2)]
203203
end

src/plot.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,11 @@ function gplot(g::AbstractGraph{T},
196196
if linetype == "curve"
197197
if arrowlengthfrac > 0.0
198198
curves_cord, arrows_cord = graphcurve(g, locs_x, locs_y, nodesize, arrowlengthfrac, arrowangleoffset, outangle)
199-
lines = curve(curves_cord...)
199+
lines = curve(curves_cord[:,1], curves_cord[:,2], curves_cord[:,3], curves_cord[:,4])
200200
arrows = line(arrows_cord)
201201
else
202202
curves_cord = graphcurve(g, locs_x, locs_y, nodesize, outangle)
203-
lines = curve(curves_cord...)
203+
lines = curve(curves_cord[:,1], curves_cord[:,2], curves_cord[:,3], curves_cord[:,4])
204204
end
205205
else
206206
if arrowlengthfrac > 0.0

0 commit comments

Comments
 (0)