Closed dpmcsuss closed 10 years ago
The problem is calculating the eigendecomposition twice. There is a workaround I can implement:
library(igraph)
A <- graph.tree(5, 3)[sparse=FALSE]
null <- matrix(0, 5, 5)
A2 <- cbind(rbind(null, A), rbind(t(A), null))
svd(A)
eigen(A2)
What seems to be tricky is the case with multiple eigenvalues.
And here is an example on how to compute the left singular values from the right ones: https://nanohub.org/tools/seteb/browser/trunk/lib/ARPACK/EXAMPLES/SVD/dsvd.f?rev=9
Should be OK now.
It appears that sometimes the sign of
X
is switched compared toY
when embedding a directed graph. For example, we should have below that the mean is around .3 for the outer product between X and Y since that should approximate the density reasonable well.. But depending on the (separate) randomness in the embedding procedure, I get either 0.2999806 or -0.2999806.You might need to run this a few times to see the phenomenon. Not sure why this is happening.