summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--python/multired.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/python/multired.py b/python/multired.py
index 0023d38..be5ddbf 100644
--- a/python/multired.py
+++ b/python/multired.py
@@ -126,7 +126,8 @@ class layer:
#K = np.multiply(self.adj_matr.sum(0), np.ones((self.N,self.N)))
#D = np.diag(np.diag(K))
K = self.adj_matr.sum(0)
- D = K * eye(self.N)
+ D = csr_matrix((self.N, self.N))
+ D.setdiag(eye(self.N) * K.transpose())
self.laplacian = csr_matrix(D - self.adj_matr)
K = self.laplacian.diagonal().sum()
self.resc_laplacian = csr_matrix(self.laplacian / K)
@@ -140,12 +141,13 @@ class layer:
#K = np.multiply(self.adj_matr.sum(0), np.ones((self.N,self.N)))
#D = np.diag(np.diag(K))
K = self.adj_matr.sum(0)
- D = K * eye(self.N)
+ D = csr_matrix((self.N, self.N))
+ D.setdiag(eye(self.N) * K.transpose())
self.laplacian = csr_matrix(D - self.adj_matr)
K = self.laplacian.diagonal().sum()
self.resc_laplacian = csr_matrix(self.laplacian / K)
self._matrix_called = True
-
+
def dump_info(self):
N, M = self.adj_matr.shape
K = self.adj_matr.nnz
@@ -178,13 +180,15 @@ class layer:
#K = np.multiply(self.adj_matr.sum(0), np.ones((self.N,self.N)))
#D = np.diag(np.diag(K))
K = self.adj_matr.sum(0)
- D = K * eye(self.N)
+ D = csr_matrix((self.N, self.N))
+ D.setdiag(eye(self.N) * K. transpose())
self.laplacian = csr_matrix(D - self.adj_matr)
K = self.laplacian.diagonal().sum()
self.resc_laplacian = csr_matrix(self.laplacian / K)
self._matrix_called = True
-
+ def dump_laplacian(self):
+ print self.laplacian
class multiplex_red: