I came across the why-laplacian-matrix-need-normalization-and-how-come-the-sqrt-of-degree-matrix.
I have a weighted adjacency matrix adjm
(file data.csv on Google Drive). The matrix adjm
is non-symmetric. I have built the directed graph graph
and then remove loops and multiple edges. The resulted graph is connected and simple. I have used the graph.laplacian()
function from the igraph
package. I expected to obtain the symmetric matrix, but the matrix L_matrix
is not symmetric.
library(igraph)
# read from file
adjm = as.matrix(read.csv("data.csv", sep=",", row.names = 1))
isSymmetric(adjm) # FALSE
graph <- graph_from_adjacency_matrix(adjm, weighted=TRUE)
table(count_multiple(graph))
# remove loops and multiple edges
graph <- simplify(graph)
is_connected(graph) # TRUE
L_matrix <- graph.laplacian(graph, norm=TRUE,
weights = E(graph)$weight,
sparse=FALSE)
isSymmetric(L_matrix) # FALSE
Edit. I tried to vary a tolerance tol
from 0.1 to 0.0001 but the result is FALSE
.
isSymmetric(L_matrix, tol = 0.01) # FALSE
The L_matrix
is square 104
by 104
matrix. I found the difference between the first row and the first column. Then I calculated the number of zeros, it is less than 104
.
test0 <- L_matrix[1,] - L_matrix[,1]
test0 <- test0[test0 == 0]
length(test0[test0 == 0])
[1] 90
Edit 2.
I want to make a spectral clustering.
Question. Why is the Laplacian Matrix not symmetric?