Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sparsify function error #14

Closed
RaniaSalama opened this issue Oct 18, 2018 · 1 comment
Closed

sparsify function error #14

RaniaSalama opened this issue Oct 18, 2018 · 1 comment

Comments

@RaniaSalama
Copy link

I am trying to use Laplacians.jl sparsify function on a Laplacian matrix (L = I - A D^{-1}), but I get an error.
The code to reproduce the error is below:

using Laplacians

n = 10

A = triu(rand(n, n))

A = A + A'

A = A - diagm(diag(A))

A = sparse(A)

d = sum(A, 2)

x = find(d)

pinvD = sparse(x, x, 1.0./d[x])

L = speye(n, n) - A * pinvD

sparsify(L)

The error message is:
WARNING: The matrix should not have any nonzero diagonal entries.
ERROR: BoundsError: attempt to access 10-element Array{Laplacians.ApproxCholPQElem{Int64},1} at index [123919728]
Stacktrace:
[1] approxCholPQDec!(::Laplacians.ApproxCholPQ{Int64}, ::Int64) at C:\Users\Rania Ibrahim.julia\v0.6\Laplacians\src\approxChol.jl:1253
[2] approxChol(::Laplacians.LLmatp{Int64,Float64}) at C:\Users\Rania Ibrahim.julia\v0.6\Laplacians\src\approxChol.jl:541
[3] #approxCholLapGreedy#189(::Float64, ::Int64, ::Float64, ::Bool, ::Array{Int64,1}, ::Laplacians.ApproxCholParams, ::Function, ::SparseMatrixCSC{Float64,Int64}) at C:\Users\Rania Ibrahim.julia\v0.6\Laplacians\src\approxChol.jl:782
[4] (::Laplacians.#kw##approxCholLapGreedy)(::Array{Any,1}, ::Laplacians.#approxCholLapGreedy, ::SparseMatrixCSC{Float64,Int64}) at .<missing>:0
[5] #approxCholLap1#205(::Float64, ::Int64, ::Float64, ::Bool, ::Array{Int64,1}, ::Laplacians.ApproxCholParams, ::Function, ::SparseMatrixCSC{Float64,Int64}) at C:\Users\Rania Ibrahim.julia\v0.6\Laplacians\src\approxChol.jl:903
[6] (::Laplacians.#kw##approxCholLap1)(::Array{Any,1}, ::Laplacians.#approxCholLap1, ::SparseMatrixCSC{Float64,Int64}) at .<missing>:0
[7] #lapWrapComponents#113(::Float64, ::Int64, ::Float64, ::Bool, ::Array{Int64,1}, ::Array{Any,1}, ::Function, ::Function, ::SparseMatrixCSC{Float64,Int64}) at C:\Users\Rania Ibrahim.julia\v0.6\Laplacians\src\solverInterface.jl:221
[8] (::Laplacians.#kw##lapWrapComponents)(::Array{Any,1}, ::Laplacians.#lapWrapComponents, ::Function, ::SparseMatrixCSC{Float64,Int64}) at .<missing>:0
[9] (::Laplacians.#kw##approxCholLap)(::Array{Any,1}, ::Laplacians.#approxCholLap, ::SparseMatrixCSC{Float64,Int64}) at .<missing>:0
[10] #sparsify#267(::Float64, ::Float64, ::Float64, ::Function, ::SparseMatrixCSC{Float64,Int64}) at C:\Users\Rania Ibrahim.julia\v0.6\Laplacians\src\sparsify.jl:21
[11] sparsify(::SparseMatrixCSC{Float64,Int64}) at C:\Users\Rania Ibrahim.julia\v0.6\Laplacians\src\sparsify.jl:17

@danspielman
Copy link
Owner

Sparsify wants the adjacency matrix of the graph as input, not the Laplacian.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants