Skip to content

Commit fab5c81

Browse files
authored
fix whitespace issues throughout codebase (#687)
1 parent a82ca43 commit fab5c81

File tree

110 files changed

+1300
-1314
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+1300
-1314
lines changed

benchmark/benchmarks.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ using PkgBenchmark
22
using LightGraphs
33

44

5-
testdatadir = joinpath(dirname(@__FILE__), "..","test","testdata")
5+
testdatadir = joinpath(dirname(@__FILE__), "..", "test", "testdata")
66
benchdatadir = joinpath(dirname(@__FILE__), "data")
77
paramsfile = joinpath(benchdatadir, "params.jld")
88

@@ -11,13 +11,13 @@ println("paramsfile = $paramsfile")
1111

1212
dg1fn = joinpath(testdatadir, "graph-5k-50k.jgz")
1313

14-
DIGRAPHS = Dict{String, DiGraph}(
14+
DIGRAPHS = Dict{String,DiGraph}(
1515
"complete100" => CompleteDiGraph(100),
1616
"5000-50000" => LightGraphs.load(dg1fn)["graph-5000-50000"],
1717
"path500" => PathDiGraph(500)
1818
)
1919

20-
GRAPHS = Dict{String, Graph}(
20+
GRAPHS = Dict{String,Graph}(
2121
"complete100" => CompleteGraph(100),
2222
"tutte" => smallgraph(:tutte),
2323
"path500" => PathGraph(500),

benchmark/edges.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
import Base: convert
22

3-
const P = Pair{Int, Int}
3+
const P = Pair{Int,Int}
44

55
convert(::Type{Tuple}, e::Pair) = (e.first, e.second)
66

77
function fille(n)
88
t = Array{LightGraphs.Edge,1}(n)
99
for i in 1:n
10-
t[i] = LightGraphs.Edge(i, i+1)
10+
t[i] = LightGraphs.Edge(i, i + 1)
1111
end
1212
return t
1313
end
1414

1515
function fillp(n)
1616
t = Array{P,1}(n)
1717
for i in 1:n
18-
t[i] = P(i, i+1)
18+
t[i] = P(i, i + 1)
1919
end
2020
return t
2121
end
2222

2323
function tsum(t)
2424
x = 0
2525
for i in 1:length(t)
26-
u,v = Tuple(t[i])
26+
u, v = Tuple(t[i])
2727
x += u
2828
x += v
2929
end

benchmark/insertions.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
@benchgroup "insertions" begin
22
n = 10000
3-
@bench "ER Generation" g = Graph($n, 16*$n)
3+
@bench "ER Generation" g = Graph($n, 16 * $n)
44
end

benchmark/max-flow.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
for n in 9:5:29
33
srand(1)
44
p = 8.0 / n
5-
A = sprand(n,n,p)
5+
A = sprand(n, n, p)
66
g = DiGraph(A)
7-
cap = round.(A*100)
7+
cap = round.(A * 100)
88
@bench "n = $n" LightGraphs.maximum_flow($g, 1, $n, $cap)
99
end
1010
end # max-flow

benchmark/parallel/egonets.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ using BenchmarkTools
1616
a = 0
1717
for u in neighbors(g, i)
1818
for v in neighbors(g, u)
19-
a += degree(g,v)
19+
a += degree(g, v)
2020
end
2121
end
2222
return a
@@ -53,7 +53,7 @@ using BenchmarkTools
5353
end
5454

5555
nv_ = 10000
56-
g = Graph(nv_, 64*nv_)
56+
g = Graph(nv_, 64 * nv_)
5757
f = vertex_function
5858
println(g)
5959

src/LightGraphs.jl

-3
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,6 @@ CombinatorialAdjacency, non_backtracking_matrix, incidence_matrix,
8686
nonbacktrack_embedding, Nonbacktracking,
8787
contract,
8888

89-
# astar
90-
a_star,
91-
9289
# persistence
9390
loadgraph, loadgraphs, savegraph, LGFormat,
9491

src/biconnectivity/biconnect.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function visit!(g::AbstractGraph, state::Biconnections, u::Integer, v::Integer)
3939
if (u == v && children > 1) || (u != v && state.low[w] >= state.depth[v])
4040
e = Edge(0, 0) #Invalid Edge, used for comparison only
4141
st = Vector{Edge}()
42-
while e != Edge(min(v, w),max(v, w))
42+
while e != Edge(min(v, w), max(v, w))
4343
e = pop!(state.stack)
4444
push!(st, e)
4545
end

src/centrality/betweenness.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function betweenness_centrality(
3636

3737
betweenness = zeros(n_v)
3838
for s in vs
39-
if degree(g,s) > 0 # this might be 1?
39+
if degree(g, s) > 0 # this might be 1?
4040
state = dijkstra_shortest_paths(g, s; allpaths=true, trackvertices=true)
4141
if endpoints
4242
_accumulate_endpoints!(betweenness, state, g, s)

src/centrality/closeness.jl

+6-6
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ function closeness_centrality(
2121
if degree(g, u) == 0 # no need to do Dijkstra here
2222
closeness[u] = 0.0
2323
else
24-
d = dijkstra_shortest_paths(g,u,distmx).dists
25-
δ = filter(x->x != typemax(x), d)
24+
d = dijkstra_shortest_paths(g, u, distmx).dists
25+
δ = filter(x -> x != typemax(x), d)
2626
σ = sum(δ)
2727
l = length(δ) - 1
2828
if σ > 0
2929
closeness[u] = l / σ
3030
if normalize
31-
n = l / (n_v-1)
31+
n = l / (n_v - 1)
3232
closeness[u] *= n
3333
end
3434
end
@@ -50,14 +50,14 @@ function parallel_closeness_centrality(
5050
if degree(g, u) == 0 # no need to do Dijkstra here
5151
closeness[u] = 0.0
5252
else
53-
d = dijkstra_shortest_paths(g,u,distmx).dists
54-
δ = filter(x->x != typemax(x), d)
53+
d = dijkstra_shortest_paths(g, u, distmx).dists
54+
δ = filter(x -> x != typemax(x), d)
5555
σ = sum(δ)
5656
l = length(δ) - 1
5757
if σ > 0
5858
closeness[u] = l / σ
5959
if normalize
60-
n = l * 1.0 / (n_v-1)
60+
n = l * 1.0 / (n_v - 1)
6161
closeness[u] *= n
6262
end
6363
end

src/centrality/degree.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ function _degree_centrality(g::AbstractGraph, gtype::Integer; normalize=true)
33
c = zeros(n_v)
44
for v in vertices(g)
55
if gtype == 0 # count both in and out degree if appropriate
6-
deg = is_directed(g)? outdegree(g, v) + indegree(g, v) : outdegree(g, v)
6+
deg = is_directed(g) ? outdegree(g, v) + indegree(g, v) : outdegree(g, v)
77
elseif gtype == 1 # count only in degree
88
deg = indegree(g, v)
99
else # count only out degree
1010
deg = outdegree(g, v)
1111
end
12-
s = normalize? (1.0 / (n_v - 1.0)) : 1.0
13-
c[v] = deg*s
12+
s = normalize ? (1.0 / (n_v - 1.0)) : 1.0
13+
c[v] = deg * s
1414
end
1515
return c
1616
end

src/centrality/katz.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function katz_centrality(g::AbstractGraph, α::Real=0.3)
3232
v = ones(Float64, nvg)
3333
spI = speye(Float64, nvg)
3434
A = adjacency_matrix(g, :in, Bool)
35-
v = (spI - α*A)\v
35+
v = (spI - α * A) \ v
3636
v /= norm(v)
3737
return v
3838
end

src/centrality/pagerank.jl

+7-7
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ is not reached within `n` iterations.
1313
function pagerank end
1414

1515
@traitfn function pagerank(g::::IsDirected, α=0.85, n=100::Integer, ϵ=1.0e-6)
16-
A = adjacency_matrix(g,:in,Float64)
17-
S = vec(sum(A,1))
18-
S = 1./S
19-
S[find(S .== Inf)]=0.0
20-
M = A' # need a separate line due to bug #17456 in julia
16+
A = adjacency_matrix(g, :in, Float64)
17+
S = vec(sum(A, 1))
18+
S = 1 ./ S
19+
S[find(S .== Inf)] = 0.0
20+
M = A' # need a separate line due to bug #17456 in julia
2121
# scaling the adjmat to stochastic adjacency matrix
2222
M = (Diagonal(S) * M)'
2323
N = Int(nv(g))
2424
# solution vector
25-
x = fill(1.0/N, N)
25+
x = fill(1.0 / N, N)
2626
# personalization vector
27-
p = fill(1.0/N, N)
27+
p = fill(1.0 / N, N)
2828
# temporary to hold the results of SpMV
2929
y = zeros(Float64, N)
3030
# adjustment for leaf nodes in digraph

src/community/cliques.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function maximal_cliques end
5353
# union!(cand, keys(nnbrs))
5454
smallcand = setdiff(cand, pivotnbrs)
5555
done = Set{T}()
56-
stack = Vector{Tuple{Set{T}, Set{T}, Set{T}}}()
56+
stack = Vector{Tuple{Set{T},Set{T},Set{T}}}()
5757
clique_so_far = Vector{T}()
5858
cliques = Vector{Array{T}}()
5959

src/community/clustering.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ end
1313

1414
function local_clustering_coefficient(g::AbstractGraph, vs = vertices(g))
1515
ntriang, nalltriang = local_clustering(g, vs)
16-
return map(p->p[2]==0? 0. : p[1]*1.0/p[2], zip(ntriang, nalltriang))
16+
return map(p -> p[2] == 0 ? 0. : p[1] * 1.0 / p[2], zip(ntriang, nalltriang))
1717
end
1818

1919
function local_clustering!(storage::AbstractVector{Bool}, g::AbstractGraph, v::Integer)
@@ -30,7 +30,7 @@ function local_clustering!(storage::AbstractVector{Bool}, g::AbstractGraph, v::I
3030
end
3131
end
3232
end
33-
return is_directed(g) ? (tcount , k*(k-1)) : (div(tcount,2) , div(k*(k-1),2))
33+
return is_directed(g) ? (tcount, k * (k - 1)) : (div(tcount, 2), div(k * (k - 1), 2))
3434
end
3535

3636
function local_clustering!(storage::AbstractVector{Bool},
@@ -101,7 +101,7 @@ function global_clustering_coefficient(g::AbstractGraph)
101101
end
102102
end
103103
k = degree(g, v)
104-
ntriangles += k*(k-1)
104+
ntriangles += k * (k - 1)
105105
end
106106
ntriangles == 0 && return 1.
107107
return c / ntriangles

src/community/core-periphery.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ function core_periphery_deg end
1414
s = sum(degs) / 2.
1515
sbest = +Inf
1616
kbest = 0
17-
for k = 1:nv(g)-1
18-
s = s + k - 1 - degree(g, p[k])
17+
for k = 1:nv(g) - 1
18+
s = s + k - 1 - degree(g, p[k])
1919
if s < sbest
2020
sbest = s
2121
kbest = k

src/community/label_propagation.jl

+9-9
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function label_propagation(g::AbstractGraph, maxiter=1000)
1414
n = nv(g)
1515
label = collect(one(T):n)
1616
active_vs = IntSet(vertices(g))
17-
c = NeighComm(collect(one(T):n), fill(-1,n), one(T))
17+
c = NeighComm(collect(one(T):n), fill(-1, n), one(T))
1818
convergence_hist = Vector{Int}()
1919
random_order = Vector{T}(n)
2020
i = 0
@@ -24,11 +24,11 @@ function label_propagation(g::AbstractGraph, maxiter=1000)
2424
i += 1
2525

2626
# processing vertices in random order
27-
for (j,node) in enumerate(active_vs)
27+
for (j, node) in enumerate(active_vs)
2828
random_order[j] = node
2929
end
3030
range_shuffle!(1:num_active, random_order)
31-
@inbounds for j=1:num_active
31+
@inbounds for j = 1:num_active
3232
u = random_order[j]
3333
old_comm = label[u]
3434
label[u] = vote!(g, label, c, u)
@@ -64,11 +64,11 @@ Fast shuffle Array `a` in UnitRange `r`.
6464
"""
6565
function range_shuffle!(r::UnitRange, a::AbstractVector)
6666
(r.start > 0 && r.stop <= length(a)) || error("out of bounds")
67-
@inbounds for i=length(r):-1:2
67+
@inbounds for i = length(r):-1:2
6868
j = rand(1:i)
6969
ii = i + r.start - 1
7070
jj = j + r.start - 1
71-
a[ii],a[jj] = a[jj],a[ii]
71+
a[ii], a[jj] = a[jj], a[ii]
7272
end
7373
end
7474

@@ -78,15 +78,15 @@ end
7878
Return the label with greatest frequency.
7979
"""
8080
function vote!(g::AbstractGraph, m::Vector, c::NeighComm, u::Integer)
81-
@inbounds for i=1:c.neigh_last-1
81+
@inbounds for i = 1:c.neigh_last - 1
8282
c.neigh_cnt[c.neigh_pos[i]] = -1
8383
end
8484
c.neigh_last = 1
8585
c.neigh_pos[1] = m[u]
8686
c.neigh_cnt[c.neigh_pos[1]] = 0
8787
c.neigh_last = 2
8888
max_cnt = 0
89-
for neigh in out_neighbors(g,u)
89+
for neigh in out_neighbors(g, u)
9090
neigh_comm = m[neigh]
9191
if c.neigh_cnt[neigh_comm] < 0
9292
c.neigh_cnt[neigh_comm] = 0
@@ -99,7 +99,7 @@ function vote!(g::AbstractGraph, m::Vector, c::NeighComm, u::Integer)
9999
end
100100
end
101101
# ties breaking randomly
102-
range_shuffle!(1:c.neigh_last-1, c.neigh_pos)
102+
range_shuffle!(1:c.neigh_last - 1, c.neigh_pos)
103103
for lbl in c.neigh_pos
104104
if c.neigh_cnt[lbl] == max_cnt
105105
return lbl
@@ -111,7 +111,7 @@ function renumber_labels!(membership::Vector, label_counters::Vector{Int})
111111
N = length(membership)
112112
(maximum(membership) > N || minimum(membership) < 1) && error("Label must between 1 and |V|")
113113
j = 1
114-
@inbounds for i=1:length(membership)
114+
@inbounds for i = 1:length(membership)
115115
k = membership[i]
116116
if k >= 1
117117
if label_counters[k] == 0

src/community/modularity.jl

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ Return a value representing Newman's modularity `Q` for the undirected graph
66
"""
77
function modularity end
88
@traitfn function modularity(g::::(!IsDirected), c::Vector)
9-
m = 2*ne(g)
9+
m = 2 * ne(g)
1010
m == 0 && return 0.
1111
nc = maximum(c)
12-
a = zeros(Int,nc)
12+
a = zeros(Int, nc)
1313
Q = 0
1414
for u in vertices(g)
15-
for v in neighbors(g,u)
15+
for v in neighbors(g, u)
1616
if u <= v
1717
c1 = c[u]
1818
c2 = c[v]
@@ -24,9 +24,9 @@ function modularity end
2424
end
2525
end
2626
end
27-
Q = Q*m
28-
@inbounds for i=1:nc
29-
Q -= a[i]*a[i]
27+
Q = Q * m
28+
@inbounds for i = 1:nc
29+
Q -= a[i] * a[i]
3030
end
31-
return Q/m/m
31+
return Q / m / m
3232
end

0 commit comments

Comments
 (0)