Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

modified laplacian_matrix to achieve speed-up #1191

Merged
merged 6 commits into from
Apr 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/linalg/spectral.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# This file provides reexported functions.

using ArnoldiMethod
using SparseArrays

"""
adjacency_matrix(g[, T=Int; dir=:out])
Expand Down Expand Up @@ -79,7 +80,8 @@ function laplacian_matrix(g::AbstractGraph{U}, T::DataType=Int; dir::Symbol=:uns
dir = is_directed(g) ? :both : :out
end
A = adjacency_matrix(g, T; dir=dir)
D = convert(SparseMatrixCSC{T,U}, Diagonal(sparse(sum(A, dims=2)[:])))
s = sum(A; dims=2)
D = convert(SparseMatrixCSC{T, U}, spdiagm(0 => s[:]))
return D - A
end

Expand Down