sbromberger / LightGraphs.jl

An optimized graphs package for the Julia programming language
Other
673 stars 185 forks source link

possible problem with contract / contract! in spectral.jl #422

Closed sbromberger closed 8 years ago

sbromberger commented 8 years ago

https://github.com/JuliaGraphs/LightGraphs.jl/blob/master/src/spectral.jl#L247-L266

Note the following loop:

    for i=1:nv(nbt.g)
        for j in neighbors(nbt.g, i)
            u = nbt.edgeidmap[Edge(j,i)]
            vertexspace[i] += edgespace[u]
        end
    end

Creating the Edge(j,i) there doesn't guarantee that src < dest. In any case, I'm probably using it wrong, but:

julia> g4 = PathDiGraph(5);
julia> n4 = Nonbacktracking(g4);
julia> v = zeros(Int, 16);
julia> contract(n4,v)
ERROR: KeyError: 2=>1 not found
 in contract! at /Users/bromberger1/.julia/v0.4/LightGraphs/src/spectral.jl:253
 in contract at /Users/bromberger1/.julia/v0.4/LightGraphs/src/spectral.jl:264

@jpfairbanks

sbromberger commented 8 years ago

All of this is just a longwinded way of saying we REALLY need tests for this stuff written by someone who understands what it's supposed to do :)

https://codecov.io/gh/JuliaGraphs/LightGraphs.jl/src/da2a26f9de12b3483514e26642aaae46fd097ad8/src/spectral.jl

Spectral.jl is at ~61%.

jpfairbanks commented 8 years ago

Oops. I did git branch instead of git checkout -b