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

Commit 70f2e7e

Browse files
committed
formatting, alignment
1 parent c6f741a commit 70f2e7e

8 files changed

Lines changed: 116 additions & 116 deletions

src/boykov_kolmogorov.jl

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ Min-Cut/Max-Flow Algorithms for Energy Minimization in Vision.
1717
function boykov_kolmogorov_impl end
1818
# see https://github.com/mauro3/SimpleTraits.jl/issues/47#issuecomment-327880153 for syntax
1919
@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
20+
residual_graph::AG::lg.IsDirected, # the input graph
21+
source::Integer, # the source vertex
22+
target::Integer, # the target vertex
2323
capacity_matrix::AbstractMatrix{T} # edge flow capacities
2424
)
2525
n = lg.nv(residual_graph)
@@ -54,14 +54,14 @@ end
5454

5555
# see https://github.com/mauro3/SimpleTraits.jl/issues/47#issuecomment-327880153 for syntax
5656
@traitfn function find_path!{T, AG<:lg.AbstractGraph{T}}(
57-
residual_graph::AG::lg.IsDirected, # the input graph
58-
source::Integer, # the source vertex
59-
target::Integer, # the target vertex
57+
residual_graph::AG::lg.IsDirected, # the input graph
58+
source::Integer, # the source vertex
59+
target::Integer, # the target vertex
6060
flow_matrix::AbstractMatrix, # the current flow matrix
6161
capacity_matrix::AbstractMatrix, # edge flow capacities
62-
PARENT::Vector, # parent table
63-
TREE::Vector, # tree table
64-
A::Vector # active set
62+
PARENT::Vector, # parent table
63+
TREE::Vector, # tree table
64+
A::Vector # active set
6565
)
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]
@@ -107,12 +107,12 @@ end
107107
end
108108

109109
function augment!(
110-
path::AbstractVector, # path from source to target
111-
flow_matrix::AbstractMatrix, # the current flow matrix
112-
capacity_matrix::AbstractMatrix, # edge flow capacities
113-
PARENT::Vector, # parent table
114-
TREE::Vector, # tree table
115-
O::Vector # orphan set
110+
path::AbstractVector, # path from source to target
111+
flow_matrix::AbstractMatrix, # the current flow matrix
112+
capacity_matrix::AbstractMatrix, # edge flow capacities
113+
PARENT::Vector, # parent table
114+
TREE::Vector, # tree table
115+
O::Vector # orphan set
116116
)
117117

118118
T = eltype(path)
@@ -147,14 +147,14 @@ function augment!(
147147
end
148148

149149
@traitfn function adopt!{T, AG<:lg.AbstractGraph{T}}(
150-
residual_graph::AG::lg.IsDirected, # the input graph
151-
source::Integer, # the source vertex
152-
target::Integer, # the target vertex
153-
flow_matrix::AbstractMatrix, # the current flow matrix
154-
capacity_matrix::AbstractMatrix, # edge flow capacities
150+
residual_graph::AG::lg.IsDirected, # the input graph
151+
source::Integer, # the source vertex
152+
target::Integer, # the target vertex
153+
flow_matrix::AbstractMatrix, # the current flow matrix
154+
capacity_matrix::AbstractMatrix, # edge flow capacities
155155
PARENT::Vector, # parent table
156156
TREE::Vector, # tree table
157-
A::Vector, # active set
157+
A::Vector, # active set
158158
O::Vector # orphan set
159159
)
160160
tree_cap(p, q) = TREE[p] == 1 ? capacity_matrix[p, q] - flow_matrix[p, q] :

src/dinic.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ Like `blocking_flow`, but requires a preallocated parent vector `P`.
3737
"""
3838
function blocking_flow! end
3939
@traitfn function blocking_flow!{T}(
40-
residual_graph::::lg.IsDirected, # the input graph
41-
source::Integer, # the source vertex
42-
target::Integer, # the target vertex
43-
capacity_matrix::AbstractMatrix{T}, # edge flow capacities
44-
flow_matrix::AbstractMatrix, # the current flow matrix
45-
P::AbstractVector{Int} # Parent vector to store Level Graph
40+
residual_graph::::lg.IsDirected, # the input graph
41+
source::Integer, # the source vertex
42+
target::Integer, # the target vertex
43+
capacity_matrix::AbstractMatrix{T}, # edge flow capacities
44+
flow_matrix::AbstractMatrix, # the current flow matrix
45+
P::AbstractVector{Int} # Parent vector to store Level Graph
4646
)
47-
n = lg.nv(residual_graph) # number of vertexes
47+
n = lg.nv(residual_graph) # number of vertexes
4848
fill!(P, -1)
4949
P[source] = -2
5050

@@ -104,9 +104,9 @@ matrix `flow_matrix`and then backtrack from `target` to `source`,
104104
augmenting flow along all possible paths.
105105
"""
106106
blocking_flow(
107-
residual_graph::lg.AbstractGraph, # the input graph
108-
source::Integer, # the source vertex
109-
target::Integer, # the target vertex
107+
residual_graph::lg.AbstractGraph, # the input graph
108+
source::Integer, # the source vertex
109+
target::Integer, # the target vertex
110110
capacity_matrix::AbstractMatrix, # edge flow capacities
111111
flow_matrix::AbstractMatrix, # the current flow matrix
112112
) = blocking_flow!(

src/edmonds_karp.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ Return the value of the maximum flow as well as the final flow matrix.
88
"""
99
function edmonds_karp_impl end
1010
@traitfn function edmonds_karp_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
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
1515
)
1616
n = lg.nv(residual_graph) # number of vertexes
1717
flow = 0

src/ext_multiroute_flow.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,10 @@ each edge whose capacity does not exceed `restriction`.
166166
function slope end
167167
# Function to get the slope of the restricted flow
168168
@traitfn function slope(
169-
flow_graph::::lg.IsDirected, # the input graph
170-
capacity_matrix::AbstractMatrix, # edge flow capacities
171-
cut::Vector, # cut information for vertices
172-
restriction::Number # value of the restriction
169+
flow_graph::::lg.IsDirected, # the input graph
170+
capacity_matrix::AbstractMatrix, # edge flow capacities
171+
cut::Vector, # cut information for vertices
172+
restriction::Number # value of the restriction
173173
)
174174
slope = 0
175175
for e in lg.edges(flow_graph)
@@ -198,12 +198,12 @@ Requires argument:
198198
- k::R<:Real # number of routes (slope of the line)
199199
"""
200200
function intersection(
201-
x1::T, # x coordinate of point 1
202-
y1::T, # y coordinate of point 1
203-
a1::Integer, # slope passing by point 1
204-
x2::T, # x coordinate of point 2
205-
y2::T, # y coordinate of point 2
206-
a2::R # slope passing by point 2
201+
x1::T, # x coordinate of point 1
202+
y1::T, # y coordinate of point 1
203+
a1::Integer, # slope passing by point 1
204+
x2::T, # x coordinate of point 2
205+
y2::T, # y coordinate of point 2
206+
a2::R # slope passing by point 2
207207
) where T<:AbstractFloat where R<:Real
208208

209209
(a1 == a2) && return -1., -1. # result will be ignored in other intersection method
@@ -222,8 +222,8 @@ Return the intersection of a set of line segments and a line of slope `k`
222222
passing by the origin. Segments are defined as a triple (x, y, slope).
223223
"""
224224
function intersection(
225-
points::Vector{Tuple{T,T,I}}, # vector of breaking points
226-
k::R # number of routes (slope of the line)
225+
points::Vector{Tuple{T,T,I}}, # vector of breaking points
226+
k::R # number of routes (slope of the line)
227227
) where T<:AbstractFloat where I<:Integer where R<:Real
228228
λ = points[1][1] # Connectivity
229229

src/kishimoto.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
# Kishimoto algorithm
33

44
@traitfn function kishimoto(
5-
flow_graph::::lg.IsDirected, # the input graph
6-
source::Integer, # the source vertex
7-
target::Integer, # the target vertex
8-
capacity_matrix::AbstractMatrix, # edge flow capacities
9-
flow_algorithm::BoykovKolmogorovAlgorithm, # keyword argument for algorithm
10-
routes::Int # keyword argument for routes
5+
flow_graph::::lg.IsDirected, # the input graph
6+
source::Integer, # the source vertex
7+
target::Integer, # the target vertex
8+
capacity_matrix::AbstractMatrix, # edge flow capacities
9+
flow_algorithm::BoykovKolmogorovAlgorithm, # keyword argument for algorithm
10+
routes::Int # keyword argument for routes
1111
)
1212
# Initialisation
1313
flow, F, labels = maximum_flow(flow_graph, source, target,
@@ -41,12 +41,12 @@ along with a multiroute cut if Boykov-Kolmogorov is used as a subroutine.
4141
"""
4242
function kishimoto end
4343
@traitfn function kishimoto(
44-
flow_graph::::lg.IsDirected, # the input graph
45-
source::Integer, # the source vertex
46-
target::Integer, # the target vertex
47-
capacity_matrix::AbstractMatrix, # edge flow capacities
48-
flow_algorithm::AbstractFlowAlgorithm, # keyword argument for algorithm
49-
routes::Int # keyword argument for routes
44+
flow_graph::::lg.IsDirected, # the input graph
45+
source::Integer, # the source vertex
46+
target::Integer, # the target vertex
47+
capacity_matrix::AbstractMatrix, # edge flow capacities
48+
flow_algorithm::AbstractFlowAlgorithm, # keyword argument for algorithm
49+
routes::Int # keyword argument for routes
5050
)
5151
# Initialisation
5252
flow, F = maximum_flow(flow_graph, source, target,

src/maximum_flow.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ function residual end
7070
# Method for Edmonds–Karp algorithm
7171

7272
@traitfn function maximum_flow(
73-
flow_graph::::lg.IsDirected, # the input graph
74-
source::Integer, # the source vertex
75-
target::Integer, # the target vertex
76-
capacity_matrix::AbstractMatrix, # edge flow capacities
77-
algorithm::EdmondsKarpAlgorithm # keyword argument for algorithm
73+
flow_graph::::lg.IsDirected, # the input graph
74+
source::Integer, # the source vertex
75+
target::Integer, # the target vertex
76+
capacity_matrix::AbstractMatrix, # edge flow capacities
77+
algorithm::EdmondsKarpAlgorithm # keyword argument for algorithm
7878
)
7979
residual_graph = residual(flow_graph)
8080
return edmonds_karp_impl(residual_graph, source, target, capacity_matrix)

src/multiroute_flow.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -187,16 +187,16 @@ julia> f, F, labels = multiroute_flow(flow_graph, 1, 8, capacity_matrix, algorit
187187
```
188188
"""
189189
function multiroute_flow(
190-
flow_graph::lg.AbstractGraph, # the input graph
191-
source::Integer, # the source vertex
192-
target::Integer, # the target vertex
193-
capacity_matrix::AbstractMatrix{T} = # edge flow capacities
194-
DefaultCapacity(flow_graph);
195-
flow_algorithm::AbstractFlowAlgorithm = # keyword argument for algorithm
196-
PushRelabelAlgorithm(),
197-
mrf_algorithm::AbstractMultirouteFlowAlgorithm = # keyword argument for algorithm
198-
KishimotoAlgorithm(),
199-
routes::R = 0 # keyword argument for number of routes (0 = all values)
190+
flow_graph::lg.AbstractGraph, # the input graph
191+
source::Integer, # the source vertex
192+
target::Integer, # the target vertex
193+
capacity_matrix::AbstractMatrix{T} = # edge flow capacities
194+
DefaultCapacity(flow_graph);
195+
flow_algorithm::AbstractFlowAlgorithm = # keyword argument for algorithm
196+
PushRelabelAlgorithm(),
197+
mrf_algorithm::AbstractMultirouteFlowAlgorithm = # keyword argument for algorithm
198+
KishimotoAlgorithm(),
199+
routes::R = 0 # keyword argument for number of routes (0 = all values)
200200
) where T where R <: Real
201201

202202
# a flow with a set of 1-disjoint paths is a classical max-flow

src/push_relabel.jl

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ Takes approximately ``\\mathcal{O}(|V|^{3})`` time.
99
"""
1010
function push_relabel end
1111
@traitfn function push_relabel{T}(
12-
residual_graph::::lg.IsDirected, # the input graph
13-
source::Integer, # the source vertex
14-
target::Integer, # the target vertex
15-
capacity_matrix::AbstractMatrix{T} # edge flow capacities
12+
residual_graph::::lg.IsDirected, # the input graph
13+
source::Integer, # the source vertex
14+
target::Integer, # the target vertex
15+
capacity_matrix::AbstractMatrix{T} # edge flow capacities
1616
)
1717

1818
n = lg.nv(residual_graph)
@@ -57,10 +57,10 @@ Push inactive node `v` into queue `Q` and activates it. Requires preallocated
5757
"""
5858

5959
function enqueue_vertex!(
60-
Q::AbstractVector,
61-
v::Integer, # input vertex
62-
active::AbstractVector{Bool},
63-
excess::AbstractVector
60+
Q::AbstractVector,
61+
v::Integer, # input vertex
62+
active::AbstractVector{Bool},
63+
excess::AbstractVector
6464
)
6565
if !active[v] && excess[v] > 0
6666
active[v] = true
@@ -78,15 +78,15 @@ matrix, and `excess`, `height, `active`, and `Q` vectors.
7878
"""
7979
function push_flow! end
8080
@traitfn function push_flow!(
81-
residual_graph::::lg.IsDirected, # the input graph
82-
u::Integer, # input from-vertex
83-
v::Integer, # input to-vetex
84-
capacity_matrix::AbstractMatrix,
85-
flow_matrix::AbstractMatrix,
86-
excess::AbstractVector,
87-
height::AbstractVector{Int},
88-
active::AbstractVector{Bool},
89-
Q::AbstractVector
81+
residual_graph::::lg.IsDirected, # the input graph
82+
u::Integer, # input from-vertex
83+
v::Integer, # input to-vetex
84+
capacity_matrix::AbstractMatrix,
85+
flow_matrix::AbstractMatrix,
86+
excess::AbstractVector,
87+
height::AbstractVector{Int},
88+
active::AbstractVector{Bool},
89+
Q::AbstractVector
9090
)
9191
flow = min(excess[u], capacity_matrix[u, v] - flow_matrix[u, v])
9292

@@ -121,13 +121,13 @@ Requires arguments:
121121
"""
122122
function gap! end
123123
@traitfn function gap!(
124-
residual_graph::::lg.IsDirected, # the input graph
125-
h::Int, # cutoff height
126-
excess::AbstractVector,
127-
height::AbstractVector{Int},
128-
active::AbstractVector{Bool},
129-
count::AbstractVector{Int},
130-
Q::AbstractVector # FIFO queue
124+
residual_graph::::lg.IsDirected, # the input graph
125+
h::Int, # cutoff height
126+
excess::AbstractVector,
127+
height::AbstractVector{Int},
128+
active::AbstractVector{Bool},
129+
count::AbstractVector{Int},
130+
Q::AbstractVector # FIFO queue
131131
)
132132
n = lg.nv(residual_graph)
133133
for v in lg.vertices(residual_graph)
@@ -147,15 +147,15 @@ Relabel a node `v` with respect to its neighbors to produce an admissable edge.
147147
"""
148148
function relabel! end
149149
@traitfn function relabel!(
150-
residual_graph::::lg.IsDirected, # the input graph
151-
v::Integer, # input vertex to be relabeled
152-
capacity_matrix::AbstractMatrix,
153-
flow_matrix::AbstractMatrix,
154-
excess::AbstractVector,
155-
height::AbstractVector{Int},
156-
active::AbstractVector{Bool},
157-
count::AbstractVector{Int},
158-
Q::AbstractVector
150+
residual_graph::::lg.IsDirected, # the input graph
151+
v::Integer, # input vertex to be relabeled
152+
capacity_matrix::AbstractMatrix,
153+
flow_matrix::AbstractMatrix,
154+
excess::AbstractVector,
155+
height::AbstractVector{Int},
156+
active::AbstractVector{Bool},
157+
count::AbstractVector{Int},
158+
Q::AbstractVector
159159
)
160160
n = lg.nv(residual_graph)
161161
count[height[v] + 1] -= 1
@@ -179,15 +179,15 @@ vertex if the excess remains non-zero.
179179
"""
180180
function discharge! end
181181
@traitfn function discharge!(
182-
residual_graph::::lg.IsDirected, # the input graph
183-
v::Integer, # vertex to be discharged
184-
capacity_matrix::AbstractMatrix,
185-
flow_matrix::AbstractMatrix,
186-
excess::AbstractVector,
187-
height::AbstractVector{Int},
188-
active::AbstractVector{Bool},
189-
count::AbstractVector{Int},
190-
Q::AbstractVector # FIFO queue
182+
residual_graph::::lg.IsDirected, # the input graph
183+
v::Integer, # vertex to be discharged
184+
capacity_matrix::AbstractMatrix,
185+
flow_matrix::AbstractMatrix,
186+
excess::AbstractVector,
187+
height::AbstractVector{Int},
188+
active::AbstractVector{Bool},
189+
count::AbstractVector{Int},
190+
Q::AbstractVector # FIFO queue
191191
)
192192
for to in lg.out_neighbors(residual_graph, v)
193193
excess[v] == 0 && break

0 commit comments

Comments
 (0)