exanauts / ColPack.jl

A Julia interface to the C++ library ColPack for graph and sparse matrix coloring.
https://exanauts.github.io/ColPack.jl/
MIT License
6 stars 0 forks source link

Non-deterministic coloring? #21

Open gdalle opened 3 weeks ago

gdalle commented 3 weeks ago

Is there an explanation for coloring to be non-deterministic with the natural order?

julia> using ColPack, SparseArrays, StableRNGs

julia> J = sprand(StableRNG(63), 100, 200, 0.04)
100×200 SparseMatrixCSC{Float64, Int64} with 828 stored entries:
...

julia> for i in 1:10
           println(maximum(get_colors(ColPackPartialColoring(J, "COLUMN_PARTIAL_DISTANCE_TWO", "NATURAL"))))
       end
19
23
22
21
22
22
23
21
22
22
gdalle commented 3 weeks ago

Even more surprising, it's the same with matrix from files:

julia> using MatrixMarket

julia> MatrixMarket.mmwrite("J.mtx", J)

julia> for i in 1:10
           println(maximum(get_colors(ColPackPartialColoring("J.mtx", "COLUMN_PARTIAL_DISTANCE_TWO", "NATURAL"))))
       end
Found file J.mtx
Graph of Market Market type: [matrix coordinate real general]
22
Found file J.mtx
Graph of Market Market type: [matrix coordinate real general]
23
Found file J.mtx
Graph of Market Market type: [matrix coordinate real general]
22
Found file J.mtx
Graph of Market Market type: [matrix coordinate real general]
20
Found file J.mtx
Graph of Market Market type: [matrix coordinate real general]
22
Found file J.mtx
Graph of Market Market type: [matrix coordinate real general]
24
Found file J.mtx
Graph of Market Market type: [matrix coordinate real general]
23
Found file J.mtx
Graph of Market Market type: [matrix coordinate real general]
23
Found file J.mtx
Graph of Market Market type: [matrix coordinate real general]
22
Found file J.mtx
Graph of Market Market type: [matrix coordinate real general]
22
gdalle commented 3 weeks ago

I just checked that the command line interface of ColPack consistently returns a coloring with 19 colors for that setup, so the problem lies with our Julia - C++ bindings

amontoison commented 3 weeks ago

I checked with the PR #22 and I confirm:

using ColPack, SparseArrays, StableRNGs
using MatrixMarket

J = sprand(StableRNG(63), 100, 200, 0.04)
MatrixMarket.mmwrite("./myfile.mtx", J)

for i in 1:10
    colpack("./myfile.mtx", "ROW_PARTIAL_DISTANCE_TWO", "NATURAL")
end

for i in 1:10
    colpack("./myfile.mtx", "COLUMN_PARTIAL_DISTANCE_TWO", "NATURAL")
end

for i in 1:10
  obj = ColPackPartialColoring(J, "ROW_PARTIAL_DISTANCE_TWO", "NATURAL")
  ncolors(obj) |> println
end

for i in 1:10
  obj = ColPackPartialColoring(J, "COLUMN_PARTIAL_DISTANCE_TWO", "NATURAL")
  ncolors(obj) |> println
end
gdalle commented 3 weeks ago

What do you confirm? That the binary is deterministic and we screwed up somewhere else in the interface?

amontoison commented 3 weeks ago

What do you confirm? That the binary is deterministic and we screwed up somewhere else in the interface?

Yes, I did something wrong in the C interface.