11using BenchmarkTools
22using LinearAlgebra
33using SparseMatrixColorings
4+ import SparseMatrixColorings as SMC
45using SparseArrays
56using StableRNGs
67
@@ -19,21 +20,23 @@ for structure in [:nonsymmetric, :symmetric],
1920 p in [2 / n, 5 / n, 10 / n]
2021
2122 problem = ColoringProblem (; structure, partition)
22- algo = GreedyColoringAlgorithm (; decompression, postprocessing= true )
23+ algo = GreedyColoringAlgorithm (
24+ RandomOrder (StableRNG (0 ), 0 ); decompression, postprocessing= true
25+ )
2326
2427 # use several random matrices to reduce variance
2528 nb_samples = 5
2629 As = [sparse (Symmetric (sprand (StableRNG (i), Bool, n, n, p))) for i in 1 : nb_samples]
27- results = [coloring (A, problem, algo) for A in As]
28- Bs = [compress (A , result) for (A, result) in zip (As, results)]
30+ results = [coloring (A, problem, algo; decompression_eltype = Float64 ) for A in As]
31+ Bs = [compress (Float64 .(A) , result) for (A, result) in zip (As, results)]
2932
30- SUITE[ :coloring ][structure][partition][decompression][ " n= $n " ][ " p= $p " ] = @benchmarkable begin
33+ bench_col = @benchmarkable begin
3134 for A in $ As
3235 coloring (A, $ problem, $ algo)
3336 end
3437 end
3538
36- SUITE[ :decompress ][structure][partition][decompression][ " n= $n " ][ " p= $p " ] = @benchmarkable begin
39+ bench_dec = @benchmarkable begin
3740 for (B, result) in zip ($ Bs, $ results)
3841 if B isa AbstractMatrix
3942 decompress (B, result)
@@ -42,4 +45,34 @@ for structure in [:nonsymmetric, :symmetric],
4245 end
4346 end
4447 end
48+
49+ SUITE[:coloring ][structure][partition][decompression][" n=$n " ][" p=$p " ] = bench_col
50+ SUITE[:decompress ][structure][partition][decompression][" n=$n " ][" p=$p " ] = bench_dec
51+ end
52+
53+ for structure in [:nonsymmetric , :symmetric ],
54+ partition in (structure == :nonsymmetric ? [:column , :row ] : [:column ]),
55+ order in [LargestFirst (), SmallestLast (), IncidenceDegree (), DynamicLargestFirst ()],
56+ n in [10 ^ 3 , 10 ^ 5 ],
57+ p in [2 / n, 5 / n, 10 / n]
58+
59+ nb_samples = 5
60+ As = [sparse (Symmetric (sprand (StableRNG (i), Bool, n, n, p))) for i in 1 : nb_samples]
61+ if structure == :symmetric
62+ gs = [SMC. AdjacencyGraph (A) for A in As]
63+ bench_ord = @benchmarkable begin
64+ for g in $ gs
65+ SMC. vertices (g, $ order)
66+ end
67+ end
68+ else
69+ gs = [SMC. BipartiteGraph (A) for A in As]
70+ valside = partition == :row ? Val (1 ) : Val (2 )
71+ bench_ord = @benchmarkable begin
72+ for g in $ gs
73+ SMC. vertices (g, $ valside, $ order)
74+ end
75+ end
76+ end
77+ SUITE[:order ][structure][partition][string (order)][" n=$n " ][" p=$p " ] = bench_ord
4578end
0 commit comments