Skip to content

Commit 3faf156

Browse files
authored
Merge branch 'main' into gd/decomp_bigger
2 parents 0384790 + ba7da77 commit 3faf156

2 files changed

Lines changed: 25 additions & 16 deletions

File tree

src/graph.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,23 +150,23 @@ function bidirectional_pattern(S::SparsityPatternCSC{T}; symmetric_pattern::Bool
150150
counter = 1
151151
for col in (n + 1):p
152152
nnz_col = colptr[col]
153-
colptr[col] = counter
153+
colptr[col] = nnzS + counter
154154
counter += nnz_col
155155
end
156156

157157
for j in 1:n
158158
for index in S.colptr[j]:(S.colptr[j + 1] - 1)
159159
i = S.rowval[index]
160160
pos = colptr[n + i]
161-
rowval[nnzS + pos] = j
162-
edge_to_index[nnzS + pos] = edge_to_index[index]
161+
rowval[pos] = j
162+
edge_to_index[pos] = edge_to_index[index]
163163
colptr[n + i] += 1
164164
end
165165
end
166166

167167
colptr[p + 1] = nnzS + counter
168168
for col in p:-1:(n + 2)
169-
colptr[col] = nnzS + colptr[col - 1]
169+
colptr[col] = colptr[col - 1]
170170
end
171171
colptr[n + 1] = nnzS + 1
172172
end

src/order.jl

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -104,29 +104,41 @@ function vertices(bg::BipartiteGraph{T}, ::Val{side}, ::LargestFirst) where {T,s
104104
return sort(vertices(bg, Val(side)); by=criterion, rev=true)
105105
end
106106

107+
const COLPACK_WARNING = """
108+
!!! danger
109+
The option `reproduce_colpack=true` induces a large slowdown to mirror the original implementation details of ColPack, it should not be used in performance-sensitive applications.
110+
This setting is mostly for the purpose of reproducing past research results which rely on implementation details.
111+
"""
112+
107113
"""
108114
DynamicDegreeBasedOrder{degtype,direction}(; reproduce_colpack=false)
109115
110116
Instance of [`AbstractOrder`](@ref) which sorts vertices using a dynamically computed degree.
111117
112-
!!! danger
113-
This order is still experimental and needs more tests, correctness is not yet guaranteed.
118+
This order works by assigning vertices to buckets based on their dynamic degree, and then updating buckets iteratively by transfering vertices between them.
114119
115120
# Type parameters
116121
117122
- `degtype::Symbol`: can be `:forward` (for the forward degree) or `:back` (for the back degree)
118123
- `direction::Symbol`: can be `:low2high` (if the order is defined from lowest to highest, i.e. `1` to `n`) or `:high2low` (if the order is defined from highest to lowest, i.e. `n` to `1`)
119124
120-
# Settings
121-
122-
- `reproduce_colpack::Bool`: whether to manage the buckets in the same way as the original ColPack implementation. When `reproduce_colpack=true`, we always append and remove vertices from the end of a bucket, which incurs a large performance penalty because every modification requires a circular permutation of the corresponding bucket. This setting is mostly for the purpose of reproducing past research results which rely on implementation details.
123-
124125
# Concrete variants
125126
126127
- [`IncidenceDegree`](@ref)
127128
- [`SmallestLast`](@ref)
128129
- [`DynamicLargestFirst`](@ref)
129130
131+
# Settings
132+
133+
- `reproduce_colpack::Bool`: whether to manage the buckets in the exact same way as the original ColPack implementation.
134+
- When `reproduce_colpack=true`, we always append and remove vertices at the end of a bucket (unilateral).
135+
- When `reproduce_colpack=false` (the default), we can append and remove vertices either at the start or at the end of a bucket (bilateral).
136+
137+
Allowing modifications on both sides of a bucket enables storage optimization, with a single fixed-size vector for all buckets instead of one dynamically-sized vector per bucket.
138+
Our implementation is optimized for this bilateral setting, which means we pay a large performance penalty to artificially imitate the unilateral setting.
139+
140+
$COLPACK_WARNING
141+
130142
# References
131143
132144
- [_ColPack: Software for graph coloring and related problems in scientific computing_](https://dl.acm.org/doi/10.1145/2513109.2513110), Gebremedhin et al. (2013), Section 5
@@ -391,8 +403,7 @@ end
391403
392404
Instance of [`AbstractOrder`](@ref) which sorts vertices from lowest to highest using the dynamic back degree.
393405
394-
!!! danger
395-
This order is still experimental and needs more tests, correctness is not yet guaranteed.
406+
$COLPACK_WARNING
396407
397408
# See also
398409
@@ -405,8 +416,7 @@ const IncidenceDegree = DynamicDegreeBasedOrder{:back,:low2high}
405416
406417
Instance of [`AbstractOrder`](@ref) which sorts vertices from highest to lowest using the dynamic back degree.
407418
408-
!!! danger
409-
This order is still experimental and needs more tests, correctness is not yet guaranteed.
419+
$COLPACK_WARNING
410420
411421
# See also
412422
@@ -419,8 +429,7 @@ const SmallestLast = DynamicDegreeBasedOrder{:back,:high2low}
419429
420430
Instance of [`AbstractOrder`](@ref) which sorts vertices from lowest to highest using the dynamic forward degree.
421431
422-
!!! danger
423-
This order is still experimental and needs more tests, correctness is not yet guaranteed.
432+
$COLPACK_WARNING
424433
425434
# See also
426435

0 commit comments

Comments
 (0)