Skip to content

Commit

Permalink
Merge pull request #8 from JuliaGraphs/vs/closeness
Browse files Browse the repository at this point in the history
Match parallel initialization to the serial one with all zeros
  • Loading branch information
jpfairbanks authored Oct 18, 2021
2 parents 6a59cc7 + ed1a2de commit bdb192a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Parallel/centrality/closeness.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ function distr_closeness_centrality(g::AbstractGraph,

n_v = Int(nv(g))
closeness = SharedVector{Float64}(n_v)
fill!(closeness, 0.0)

@sync @distributed for u in vertices(g)
if degree(g, u) == 0 # no need to do Dijkstra here
Expand All @@ -34,7 +35,7 @@ function threaded_closeness_centrality(g::AbstractGraph,
normalize=true)::Vector{Float64}

n_v = Int(nv(g))
closeness = Vector{Float64}(undef, n_v)
closeness = zeros(Float64, n_v)

Base.Threads.@threads for u in vertices(g)
if degree(g, u) == 0 # no need to do Dijkstra here
Expand Down

0 comments on commit bdb192a

Please sign in to comment.