Skip to content

Commit

Permalink
32-bit compatibility (sbromberger#999)
Browse files Browse the repository at this point in the history
* attempt 32-bit compatibility

* don't allow downsampling to Int32: introduces accuracy bugs

* add 0.7 and nightly tests

* allow integers in betweenness centrality

* attempt to fix parallel 32-bit

* work around splitrange issue

* Revert "work around splitrange issue"

This reverts commit 58cbcf8.

* splitrange overload
  • Loading branch information
ChrisRackauckas authored and sbromberger committed Aug 25, 2018
1 parent 9716138 commit a8a0356
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 10 deletions.
43 changes: 43 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
environment:
matrix:
- julia_version: 0.7
- julia_version: 1
- julia_version: nightly

platform:
- x86 # 32-bit
- x64 # 64-bit

# # Uncomment the following lines to allow failures on nightly julia
# # (tests will run but not make your overall status red)
# matrix:
# allow_failures:
# - julia_version: nightly

branches:
only:
- master
- /release-.*/

notifications:
- provider: Email
on_build_success: false
on_build_failure: false
on_build_status_changed: false

install:
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))

build_script:
- echo "%JL_BUILD_SCRIPT%"
- C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"

test_script:
- echo "%JL_TEST_SCRIPT%"
- C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"

# # Uncomment to support code coverage upload. Should only be enabled for packages
# # which would have coverage gaps without running on Windows
# on_success:
# - echo "%JL_CODECOV_SCRIPT%"
# - C:\julia\bin\julia -e "%JL_CODECOV_SCRIPT%"
5 changes: 5 additions & 0 deletions src/Parallel/Parallel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ include("centrality/stress.jl")
include("distance.jl")
include("traversals/bfs.jl")
include("traversals/greedy_color.jl")

# Overload until https://github.com/JuliaLang/julia/pull/28651
import Distributed: splitrange
splitrange(N::Integer, np::Integer) = splitrange(Int.(N), np)

end
1 change: 1 addition & 0 deletions src/Parallel/centrality/radiality.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ function radiality_centrality(g::AbstractGraph)::Vector{Float64}
d = LightGraphs.dijkstra_shortest_paths(g, vs[i])
maxdists[i] = maximum(d.dists)
meandists[i] = sum(d.dists) / (n_v - 1)
nothing
end
dmtr = maximum(maxdists)
radialities = collect(meandists)
Expand Down
5 changes: 2 additions & 3 deletions src/Parallel/centrality/stress.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
function stress_centrality(g::AbstractGraph,
vs::AbstractVector=vertices(g))::Vector{Int}
vs::AbstractVector=vertices(g))::Vector{Int64}

n_v = nv(g)
k = length(vs)
isdir = is_directed(g)

# Parallel reduction
stress = @distributed (+) for s in vs
temp_stress = zeros(Int, n_v)
temp_stress = zeros(Int64, n_v)
if degree(g, s) > 0 # this might be 1?
state = LightGraphs.dijkstra_shortest_paths(g, s; allpaths=true, trackvertices=true)
LightGraphs._stress_accumulate_basic!(temp_stress, state, g, s)
Expand All @@ -19,4 +19,3 @@ end

stress_centrality(g::AbstractGraph, k::Integer) =
stress_centrality(g, sample(vertices(g), k))

4 changes: 2 additions & 2 deletions src/centrality/betweenness.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function _accumulate_endpoints!(betweenness::Vector{Float64},
return nothing
end

function _rescale!(betweenness::Vector{Float64}, n::Integer, normalize::Bool, directed::Bool, k::Int)
function _rescale!(betweenness::Vector{Float64}, n::Integer, normalize::Bool, directed::Bool, k::Integer)
if normalize
if n <= 2
do_scale = false
Expand All @@ -136,7 +136,7 @@ function _rescale!(betweenness::Vector{Float64}, n::Integer, normalize::Bool, di
scale = scale * n / k
end
betweenness .*= scale

end
return nothing
end
2 changes: 1 addition & 1 deletion src/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ can accommodate all vertices.
"""
function squash(g::AbstractGraph)
gtype = is_directed(g) ? DiGraph : Graph
validtypes = [UInt8, UInt16, UInt32, UInt64, Int]
validtypes = [UInt8, UInt16, UInt32, UInt64, Int64]
nvg = nv(g)
for T in validtypes
nvg < typemax(T) && return gtype{T}(g)
Expand Down
2 changes: 1 addition & 1 deletion src/linalg/graphmatrices.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const SparseMatrix{T} = SparseMatrixCSC{T,Int64}
const SparseMatrix{T} = SparseMatrixCSC{T,Int}

"""
GraphMatrix{T}
Expand Down
6 changes: 3 additions & 3 deletions src/persistence/lg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct LGHeader
ne::Int
is_directed::Bool
name::String
ver::Int
ver::Int64
dtype::DataType
code::String
end
Expand All @@ -29,7 +29,7 @@ function show(io::IO, h::LGHeader)
print(io, "$(h.nv),$(h.ne),$isdir,$(h.name),$(h.ver),$(h.dtype),$(h.code)")
end

LGHeader(nv::Int, ne::Int, is_directed::Bool, name::AbstractString) =
LGHeader(nv::Int, ne::Int, is_directed::Bool, name::AbstractString) =
LGHeader(nv, ne, is_directed, name, 1, Int64, "simplegraph")

function _lg_read_one_graph(f::IO, header::LGHeader)
Expand Down Expand Up @@ -83,7 +83,7 @@ end




"""
loadlg_mult(io)
Expand Down

0 comments on commit a8a0356

Please sign in to comment.