Skip to content
This repository was archived by the owner on Oct 22, 2021. It is now read-only.

Commit eff807b

Browse files
simonschoellymatbesancon
authored andcommitted
Added fixes for Julia 1.0 (#19)
* added fixes for Julia 1.0 * changed .travis.yml to julia version 0.7, 1.0 and nightly * updated appveyor script * added using InteractiveUtils so versioninfo() can still be used * replaced content of appveyor.yml with new version from README * forgot to uncomment a line * changed indentation * added using Pkg to appveyor script * added second using Pkg to appveyor.yml * changed Clp requirement in test to v0.5 * changed Clp requirement in test to v0.5
1 parent c64661c commit eff807b

14 files changed

+76
-74
lines changed

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ os:
44
- linux
55
- osx
66
julia:
7-
- 0.6
7+
- 0.7
8+
- 1.0
89
- nightly
910

1011
matrix:
@@ -34,4 +35,4 @@ after_success:
3435
- julia -e 'cd(Pkg.dir("LightGraphsFlows")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
3536
# Build documentation
3637
- julia -e 'Pkg.add("Documenter")'
37-
- julia -e 'cd(Pkg.dir("LightGraphsFlows")); include(joinpath("docs", "make.jl"))'
38+
- julia -e 'cd(Pkg.dir("LightGraphsFlows")); include(joinpath("docs", "make.jl"))'

REQUIRE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
julia 0.6
2-
LightGraphs 0.12
1+
julia 0.7
2+
LightGraphs 1.1.0
33
SimpleTraits 0.6
44
MathProgBase 0.7

appveyor.yml

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
environment:
22
matrix:
3-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
4-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"
5-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
6-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
7-
8-
## uncomment the following lines to allow failures on nightly julia
9-
## (tests will run but not make your overall status red)
10-
#matrix:
11-
# allow_failures:
12-
# - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
13-
# - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
3+
- julia_version: 0.7
4+
- julia_version: 1
5+
- julia_version: nightly
6+
7+
platform:
8+
- x86 # 32-bit
9+
- x64 # 64-bit
10+
11+
# # Uncomment the following lines to allow failures on nightly julia
12+
# # (tests will run but not make your overall status red)
13+
matrix:
14+
allow_failures:
15+
- julia_version: nightly
1416

1517
branches:
1618
only:
@@ -24,24 +26,19 @@ notifications:
2426
on_build_status_changed: false
2527

2628
install:
27-
- ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"
28-
# If there's a newer build queued for the same PR, cancel this one
29-
- ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod `
30-
https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | `
31-
Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { `
32-
throw "There are newer queued builds for this pull request, failing early." }
33-
# Download most recent Julia Windows binary
34-
- ps: (new-object net.webclient).DownloadFile(
35-
$env:JULIA_URL,
36-
"C:\projects\julia-binary.exe")
37-
# Run installer silently, output to C:\projects\julia
38-
- C:\projects\julia-binary.exe /S /D=C:\projects\julia
29+
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))
3930

4031
build_script:
4132
# Need to convert from shallow to complete for Pkg.clone to work
4233
- IF EXIST .git\shallow (git fetch --unshallow)
43-
- C:\projects\julia\bin\julia -e "versioninfo();
44-
Pkg.clone(pwd(), \"LightGraphsFlows\"); Pkg.build(\"LightGraphsFlows\")"
34+
- C:\julia\bin\julia -e "using InteractiveUtils, Pkg; versioninfo();
35+
Pkg.clone(pwd(), \"LightGraphsFlows\"); Pkg.build(\"LightGraphsFlows\")"
4536

4637
test_script:
47-
- C:\projects\julia\bin\julia -e "Pkg.test(\"LightGraphsFlows\")"
38+
- C:\julia\bin\julia -e "using Pkg; Pkg.test(\"LightGraphsFlows\")"
39+
40+
# # Uncomment to support code coverage upload. Should only be enabled for packages
41+
# # which would have coverage gaps without running on Windows
42+
# on_success:
43+
# - echo "%JL_CODECOV_SCRIPT%"
44+
# - C:\julia\bin\julia -e "%JL_CODECOV_SCRIPT%"

src/LightGraphsFlows.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import SimpleTraits
88
using MathProgBase.HighLevelInterface: linprog
99
using MathProgBase.SolverInterface: AbstractMathProgSolver
1010

11-
import Base: getindex, size, transpose, ctranspose
11+
using SparseArrays: spzeros
12+
using Markdown: @doc_str
13+
14+
import Base: getindex, size, transpose, adjoint
1215

1316
include("maximum_flow.jl")
1417
include("edmonds_karp.jl")

src/boykov_kolmogorov.jl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ Min-Cut/Max-Flow Algorithms for Energy Minimization in Vision.
1616
"""
1717
function boykov_kolmogorov_impl end
1818
# see https://github.com/mauro3/SimpleTraits.jl/issues/47#issuecomment-327880153 for syntax
19-
@traitfn function boykov_kolmogorov_impl{T, U, AG<:lg.AbstractGraph{U}}(
20-
residual_graph::AG::lg.IsDirected, # the input graph
21-
source::Integer, # the source vertex
22-
target::Integer, # the target vertex
23-
capacity_matrix::AbstractMatrix{T} # edge flow capacities
24-
)
19+
@traitfn function boykov_kolmogorov_impl(
20+
residual_graph::AG::lg.IsDirected, # the input graph
21+
source::Integer, # the source vertex
22+
target::Integer, # the target vertex
23+
capacity_matrix::AbstractMatrix{T} # edge flow capacities
24+
) where {T, U, AG<:lg.AbstractGraph{U}}
2525
n = lg.nv(residual_graph)
2626

2727
flow = 0
@@ -53,7 +53,7 @@ function boykov_kolmogorov_impl end
5353
end
5454

5555
# see https://github.com/mauro3/SimpleTraits.jl/issues/47#issuecomment-327880153 for syntax
56-
@traitfn function find_path!{T, AG<:lg.AbstractGraph{T}}(
56+
@traitfn function find_path!(
5757
residual_graph::AG::lg.IsDirected, # the input graph
5858
source::Integer, # the source vertex
5959
target::Integer, # the target vertex
@@ -62,7 +62,7 @@ end
6262
PARENT::Vector, # parent table
6363
TREE::Vector, # tree table
6464
A::Vector # active set
65-
)
65+
) where {T, AG<:lg.AbstractGraph{T}}
6666
tree_cap(p, q) = TREE[p] == one(T) ? capacity_matrix[p, q] - flow_matrix[p, q] :
6767
capacity_matrix[q, p] - flow_matrix[q, p]
6868
while !isempty(A)
@@ -72,7 +72,7 @@ end
7272
if TREE[q] == zero(T)
7373
TREE[q] = TREE[p]
7474
PARENT[q] = p
75-
unshift!(A, q)
75+
pushfirst!(A, q)
7676
end
7777
if TREE[q] zero(T) && TREE[q] TREE[p]
7878
# p -> source
@@ -134,19 +134,19 @@ function augment!(
134134
if flow_matrix[p, q] == capacity_matrix[p, q]
135135
if TREE[p] == TREE[q] == one(T)
136136
PARENT[q] = zero(T)
137-
unshift!(O, q)
137+
pushfirst!(O, q)
138138
end
139139
if TREE[p] == TREE[q] == 2
140140
PARENT[p] = zero(T)
141-
unshift!(O, p)
141+
pushfirst!(O, p)
142142
end
143143
end
144144
end
145145

146146
return Δ
147147
end
148148

149-
@traitfn function adopt!{T, AG<:lg.AbstractGraph{T}}(
149+
@traitfn function adopt!(
150150
residual_graph::AG::lg.IsDirected, # the input graph
151151
source::Integer, # the source vertex
152152
target::Integer, # the target vertex
@@ -156,7 +156,7 @@ end
156156
TREE::Vector, # tree table
157157
A::Vector, # active set
158158
O::Vector # orphan set
159-
)
159+
) where {T, AG<:lg.AbstractGraph{T}}
160160
tree_cap(p, q) = TREE[p] == 1 ? capacity_matrix[p, q] - flow_matrix[p, q] :
161161
capacity_matrix[q, p] - flow_matrix[q, p]
162162
while !isempty(O)
@@ -183,11 +183,11 @@ end
183183
for q in lg.neighbors(residual_graph, p)
184184
if TREE[q] == TREE[p]
185185
if tree_cap(q, p) > 0
186-
unshift!(A, q)
186+
pushfirst!(A, q)
187187
end
188188
if PARENT[q] == p
189189
PARENT[q] = zero(T)
190-
unshift!(O, q)
190+
pushfirst!(O, q)
191191
end
192192
end
193193
end

src/dinic.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ with edge flow capacities in `capacity_matrix` using
77
Return the value of the maximum flow as well as the final flow matrix.
88
"""
99
function dinic_impl end
10-
@traitfn function dinic_impl{T}(
11-
residual_graph::::lg.IsDirected, # the input graph
12-
source::Integer, # the source vertex
13-
target::Integer, # the target vertex
14-
capacity_matrix::AbstractMatrix{T} # edge flow capacities
15-
)
10+
@traitfn function dinic_impl(
11+
residual_graph::::lg.IsDirected, # the input graph
12+
source::Integer, # the source vertex
13+
target::Integer, # the target vertex
14+
capacity_matrix::AbstractMatrix{T} # edge flow capacities
15+
) where {T}
1616
n = lg.nv(residual_graph) # number of vertexes
1717
flow_matrix = zeros(T, n, n) # initialize flow matrix
1818
P = zeros(Int, n) # Sharable parent vector
@@ -36,14 +36,14 @@ end
3636
Like `blocking_flow`, but requires a preallocated parent vector `P`.
3737
"""
3838
function blocking_flow! end
39-
@traitfn function blocking_flow!{T}(
39+
@traitfn function blocking_flow!(
4040
residual_graph::::lg.IsDirected, # the input graph
4141
source::Integer, # the source vertex
4242
target::Integer, # the target vertex
4343
capacity_matrix::AbstractMatrix{T}, # edge flow capacities
4444
flow_matrix::AbstractMatrix, # the current flow matrix
4545
P::AbstractVector{Int} # Parent vector to store Level Graph
46-
)
46+
) where {T}
4747
n = lg.nv(residual_graph) # number of vertexes
4848
fill!(P, -1)
4949
P[source] = -2
@@ -56,7 +56,7 @@ function blocking_flow! end
5656
for v in lg.outneighbors(residual_graph, u)
5757
if P[v] == -1 && capacity_matrix[u, v] > flow_matrix[u, v]
5858
P[v] = u
59-
unshift!(Q, v)
59+
pushfirst!(Q, v)
6060
end
6161
end
6262
end

src/edmonds_karp.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ Compute the maximum flow in flow graph `residual_graph` between `source` and
77
Return the value of the maximum flow as well as the final flow matrix.
88
"""
99
function edmonds_karp_impl end
10-
@traitfn function edmonds_karp_impl{T}(
10+
@traitfn function edmonds_karp_impl(
1111
residual_graph::::lg.IsDirected, # the input graph
1212
source::Integer, # the source vertex
1313
target::Integer, # the target vertex
1414
capacity_matrix::AbstractMatrix{T} # edge flow capacities
15-
)
15+
) where {T}
1616
n = lg.nv(residual_graph) # number of vertexes
1717
flow = 0
1818
flow_matrix = zeros(T, n, n) # initialize flow matrix
@@ -111,7 +111,7 @@ function fetch_path! end
111111
if capacity_matrix[u, v] - flow_matrix[u, v] > 0 && P[v] == -1
112112
P[v] = u
113113
if S[v] == -1
114-
unshift!(Q_f, v)
114+
pushfirst!(Q_f, v)
115115
else
116116
return v, P, S, 0 # 0 indicates success
117117
end
@@ -126,7 +126,7 @@ function fetch_path! end
126126
S[u] = v
127127
P[u] != -1 && return u, P, S, 0 # 0 indicates success
128128

129-
unshift!(Q_r, u)
129+
pushfirst!(Q_r, u)
130130
end
131131

132132
end

src/ext_multiroute_flow.jl

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# EMRF (Extended Multiroute Flow) algorithms
12
"""
23
emrf(flow_graph, source, target, capacity_matrix, flow_algorithm, routes=0)
34
@@ -13,7 +14,6 @@ multiroute flow function.
1314
### References
1415
- [Extended Multiroute Flow algorithm](http://dx.doi.org/10.1016/j.disopt.2016.05.002)
1516
"""
16-
# EMRF (Extended Multiroute Flow) algorithms
1717
function emrf(
1818
flow_graph::lg.AbstractGraph, # the input graph
1919
source::Integer, # the source vertex
@@ -104,12 +104,12 @@ Calculates the breaking of the restricted max-flow from a set of auxiliary point
104104
for `flow_graph` from `source to `target` using capacities in `capacity_matrix`.
105105
"""
106106
function breakingPoints end
107-
@traitfn function breakingPoints{T}(
107+
@traitfn function breakingPoints(
108108
flow_graph::::lg.IsDirected, # the input graph
109109
source::Integer, # the source vertex
110110
target::Integer, # the target vertex
111111
capacity_matrix::AbstractMatrix{T} # edge flow capacities
112-
)
112+
) where {T}
113113
auxpoints = auxiliaryPoints(flow_graph, source, target, capacity_matrix)
114114
λ = length(auxpoints) - 1
115115
left_index = 1
@@ -131,6 +131,9 @@ function breakingPoints end
131131
return breakingpoints
132132
end
133133

134+
# Function to get the nonzero min and max function of a Matrix
135+
# note: this is more efficient than maximum() / minimum() / extrema()
136+
# since we have to ignore zero values.
134137
"""
135138
minmaxCapacity(capacity_matrix)
136139
@@ -139,10 +142,6 @@ Return the nonzero min and max function of `capacity_matrix`.
139142
Note: this is more efficient than maximum() / minimum() / extrema()
140143
since we have to ignore zero values.
141144
"""
142-
143-
# Function to get the nonzero min and max function of a Matrix
144-
# note: this is more efficient than maximum() / minimum() / extrema()
145-
# since we have to ignore zero values.
146145
function minmaxCapacity(
147146
capacity_matrix::AbstractMatrix{T} # edge flow capacities
148147
) where T

src/maximum_flow.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ getindex(d::DefaultCapacity{T}, s::Integer, t::Integer) where T = if lg.has_edge
4848
# isassigned{T<:Integer}(d::DefaultCapacity{T}, u::T, v::T) = (u in 1:d.nv) && (v in 1:d.nv)
4949
size(d::DefaultCapacity) = (Int(d.nv), Int(d.nv))
5050
transpose(d::DefaultCapacity) = DefaultCapacity(reverse(d.flow_graph))
51-
ctranspose(d::DefaultCapacity) = DefaultCapacity(reverse(d.flow_graph))
51+
adjoint(d::DefaultCapacity) = DefaultCapacity(reverse(d.flow_graph))
5252

5353
"""
5454
residual(flow_graph)

src/push_relabel.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ FIFO push relabel algorithm with gap heuristic.
88
Takes approximately ``\\mathcal{O}(|V|^{3})`` time.
99
"""
1010
function push_relabel end
11-
@traitfn function push_relabel{T}(
11+
@traitfn function push_relabel(
1212
residual_graph::::lg.IsDirected, # the input graph
1313
source::Integer, # the source vertex
1414
target::Integer, # the target vertex
1515
capacity_matrix::AbstractMatrix{T} # edge flow capacities
16-
)
16+
) where {T}
1717

1818
n = lg.nv(residual_graph)
1919
flow_matrix = zeros(T, n, n)
@@ -55,7 +55,6 @@ end
5555
Push inactive node `v` into queue `Q` and activates it. Requires preallocated
5656
`active` and `excess` vectors.
5757
"""
58-
5958
function enqueue_vertex!(
6059
Q::AbstractVector,
6160
v::Integer, # input vertex
@@ -64,7 +63,7 @@ function enqueue_vertex!(
6463
)
6564
if !active[v] && excess[v] > 0
6665
active[v] = true
67-
unshift!(Q, v)
66+
pushfirst!(Q, v)
6867
end
6968
return nothing
7069
end

test/REQUIRE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Clp 0.4
1+
Clp 0.5

test/maximum_flow.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
@test d[s, t] == 0
4545
@test size(d) == (nvertices, nvertices)
4646
@test typeof(transpose(d)) <: LightGraphsFlows.DefaultCapacity
47-
@test typeof(ctranspose(d)) <: LightGraphsFlows.DefaultCapacity
47+
@test typeof(adjoint(d)) <: LightGraphsFlows.DefaultCapacity
4848

4949
# Test all algorithms - type instability in PushRelabel #553
5050
for ALGO in [EdmondsKarpAlgorithm, DinicAlgorithm, BoykovKolmogorovAlgorithm, PushRelabelAlgorithm]

test/mincost.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Clp: ClpSolver
2+
using SparseArrays: spzeros
23

34
@testset "Minimum-cost flow" begin
45

test/runtests.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
using LightGraphsFlows
2-
using Base.Test
2+
using Test
33
import LightGraphs
44
import SimpleTraits
55
const lg = LightGraphs
66

7+
using LinearAlgebra: diag
8+
79
const testdir = dirname(@__FILE__)
810

911
testgraphs(g) = [g, lg.Graph{UInt8}(g), lg.Graph{Int16}(g)]

0 commit comments

Comments
 (0)