GithubHelp home page GithubHelp logo

danspielman / laplacians.jl Goto Github PK

View Code? Open in Web Editor NEW
214.0 214.0 39.0 54.84 MB

Algorithms inspired by graph Laplacians: linear equation solvers, sparsification, clustering, optimization, etc.

License: Other

HTML 29.05% Julia 18.55% Jupyter Notebook 52.18% MATLAB 0.22%

laplacians.jl's People

Contributors

bnels avatar danspielman avatar github-actions[bot] avatar jacksonthea avatar johnchrishays avatar juliatagbot avatar mortenpi avatar pratyai avatar raoanupb avatar rjkyng avatar sachdevasushant avatar serbanstan avatar stanleyjs avatar tkelman avatar willow-ahrens avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laplacians.jl's Issues

Chimera occasionally returns weighted graph

The function chimera(n) and chimera(n,k) are supposed to return unweighted graphs, but occasionally return weighted graphs with tiny weights. Attaching a simple example with chimera(30,52).
I suspect the reason is that the function chimera_ijv does not run unweight! when the version is not V06.
Screenshot 2023-10-23 at 4 21 17 PM

Sparsification implemented without replacement?

I greatly appreciate these implementations, particularly in verifying my understanding of your papers (ironically I find code can be more readable than natural language sometimes).

I'm not a julia native so apologies in advance if I'm mistaken, but isn't this an implementation of sampling without replacement (rather than with replacement as specified in the paper)?

Simple test failure on Julia 1.4 with cholmod defaults on common_struct due to threading changes

Running Pkg.test on Julia 1.4 gives an error when getting default parameters in Cholmod. This occurs because of some changes due to Threading in Julia where common_struct is now allocated per thread. The fix is simple.

Replace line 22 and line 52 in src/from_cholmod.jl with

cm = ba.defaults(ba.common_struct[Threads.threadid()])

After that change, tests pass for me on 1.4.1. Happy to submit a pull request, but that seems like much more work than needed for a very simple change!

This does not work under 1.3, however, so if you want backwards compat, then you might need an

@static if VERSION >= v"1.4"
    cm = ba.defaults(ba.common_struct[Threads.threadid()])
else
    cm = ba.defaults(ba.common_struct)
end

This works under 1.3 and 1.4.

sparsify function error

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

Receiving an Error by Using the Package with Julia v1.0.4

I am trying to use Laplacians package with Julia version- 1.0.4, however I get the following message (error):
"Entropy pool not available to seed RNG; using ad-hoc entropy sources."

I appreciate if anyone help me with this. I am assuming that this is an error that causes an issue to use the package properly since I am not getting the correct results using some of the existing functions in the package (sparsify() and maxflow()).

I am not sure if the package necessarily needs Julia- v1.0.0 to be properly used.

Inexact error using fiedler

I have raised an issue that I face in the julialanguage forum here. It would be great if I could know the reason for this error.

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

Extracting LDL decomposition from sampling solver

I am working on my own implementation of the Laplacian system solver from http://arxiv.org/pdf/1605.02353v1.pdf . I have run into issues, and so I am looking at the reference implementation provided here for guidance. However, I have some questions about the way that the implementation here produces the matrices U and D. The procedure samplingLapSolver appears to compute the matrices U and D as in the paper and do CG with f(x) = U \ (D \ (U' \x )) as a preconditioner. However, when the matrices U and D are multiplied as U'_D_U, the results do not match the original matrix within the factor provided in the paper:

defaultSamplingParams = samplingParams(0.5, 0.02, 1e0, 1000, 20, false,false,1e-3)
#even if beta is changed back to 1e3, the eigenvalue bounds do not hold (in fact, they are even worse)
U = Laplacians.buildSolver(grid3(4))[3]
d = Laplacians.buildSolver(grid3(4))[4];
w = Laplacians.lap(grid3(4));
z1 = U'*diagm(d)*U
test1 = sort(eig(full(3*w/2 - z1))[1])[1]
test2 = sort(eig(full(z1- w/2))[1])[1]
println(test1, " ", test2) #these need to both be positive
-6.353282856003461 -2.137250265528108

Multiplying by the permutation matrix doesn't change this
ord = Laplacians.buildSolver(grid3(4))[5];
for i = 1:64
ordmat[i,ord[i]] = 1
end
z1 = ordmat*U'*diagm(d)*U*ordmat'
compute tests
-5.893602233549341 -2.6099184213847844

grid3 is just an alias for wGrid3, taken with fixed unit edge weight.

Can someone please explain how to extract the explicit cholesky decomposition from the solver?

akpwU breaks

akpwU breaks on chimera(10,2): it returns a disconnected graph!

General solver for SDD matrices

In the documentation here it says it's possible to write a wrapper for general SDD matrices that don't necessarily satisfy the M-matrix condition, given that the doc I'm referring to is quite old, I was wondering has this been implemented yet? If not, are there plans for it in the future? Thanks!

Installation error for julia v"1.0.3"

I'm using Julia v 1.0.3 on Mac Mojave 10.14.3. The README in this repo says this package supports Julia v1.0.0. And I suppose it should support v1.0.3 as well.

But when I tried to install it using the package manager, the following error showed up:

(v1.0) pkg> add Laplacians#master
  Updating git-repo `https://github.com/danspielman/Laplacians.jl.git`
 Resolving package versions...
ERROR: Unsatisfiable requirements detected for package DebuggerFramework [67417a49]:
 DebuggerFramework [67417a49] log:
 ├─possible versions are: 0.1.0-0.1.2 or uninstalled
 ├─restricted by compatibility requirements with Atom [c52e3926] to versions: 0.1.0-0.1.2
 │ └─Atom [c52e3926] log:
 │   ├─possible versions are: [0.1.0-0.1.1, 0.2.0-0.2.1, 0.3.0, 0.4.0-0.4.6, 0.5.0-0.5.10, 0.6.0-0.6.17, 0.7.0-0.7.15, 0.8.0-0.8.4] or uninstalled
 │   └─restricted to versions 0.7.14 by an explicit requirement, leaving only versions 0.7.14
 └─restricted by julia compatibility requirements to versions: uninstalled — no versions left

I'm wondering if anyone has encountered a similar problem? Am I missing something here?

Thanks in advance!

Plots.jl as a dependency

Is there any way this package could work without requiring Plots.jl as a dependency? RecipesBase.jl is a potential workaround.

Laplacian operator on non-square grid

Not strictly an issue, but I've noticed that lap(grid2(dims1, dims2)) produces the matrix relevant to a (dims2, dims1) problem. Similarly, lap(grid3(dims1, dims2, dims3)) produces the matrix relevant to a (dims3, dims2, dims1) problem.

For example, when using harmonic_interp on a matrix that is not square, one has to reverse the index dimensions to get the correct result. For example

a = grid2(3,4)
S = [2;3;4;5;6;9;11;12]
vals = repeat([1,0.75,0.5,0.25],1,3)[:]
x = harmonic_interp(a, S, vals[S])
y = reshape(x,4,3)

will work, but replacing the first line with

a = grid2(4,3)

will not. Posting this here in case it will avoid confusion for others.

Find ApproxCholLap function didn't finish in one example

Hi,

Here is the thing I noticed: when I tried to use approxCholLap function to deal with one graph, it didn't finish within a reasonable time. However, cholLap function went on well with the same graph. Therefore, I just want to report this unsuccessful case.
Here is the code that didn't work:
https://github.com/qlyu2016/Homework/tree/master/EffectiveResistancesJulia
main.jl is the main entry for testing.
ca-GrQc stores the data file.

Thanks,
Qian Lyu

Julia 0.5 incompabitilities

I'm relatively new to Julia and I've noticed that the mapweight is now breaking for all the examples shown:

m = grid2(100)
a = mapweight(m,x->1/(rand(1)[1]));

LoadError: type SparseMatrixCSC is immutable
while loading In[19], in expression starting on line 2

 in mapweight(::SparseMatrixCSC{Float64,Int64}, ::Function) at /Laplacians/src/graphOps.jl:49

ReadIJ not working

(test.txt consists of 1 line, 1 2)

julia> VERSION
v"1.0.2"

julia> A = readIJ("test.txt")
ERROR: MethodError: Cannot convert an object of type SubString{String} to an object of type Int64
Closest candidates are:
convert(::Type{T<:Number}, ::T<:Number) where T<:Number at number.jl:6
convert(::Type{T<:Number}, ::Number) where T<:Number at number.jl:7
convert(::Type{T<:Integer}, ::Ptr) where T<:Integer at pointer.jl:23
...
Stacktrace:
[1] setindex!(::Array{Int64,2}, ::SubString{String}, ::Int64) at .\array.jl:769
[2] copyto!(::IndexLinear, ::Array{Int64,2}, ::IndexLinear, ::Array{Any,2}) at .\abstractarray.jl:731
[3] copyto! at .\abstractarray.jl:723 [inlined]
[4] Type at .\array.jl:497 [inlined]
[5] convert(::Type{Array{Int64,2}}, ::Array{Any,2}) at .\array.jl:489
[6] readIJ(::String, ::Char) at C:\Users\T-YAPE.juliapro\packages\Laplacians\afmZe\src\IO.jl:7
[7] readIJ(::String) at C:\Users\T-YAPE.juliapro\packages\Laplacians\afmZe\src\IO.jl:4
[8] top-level scope at none:0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.