Skip to content

Commit

Permalink
Fixes update issues
Browse files Browse the repository at this point in the history
  • Loading branch information
EiffL committed Apr 20, 2018
1 parent c1d75ba commit bf2183e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
11 changes: 4 additions & 7 deletions pygsp/graphs/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,20 +568,17 @@ def create_incidence_matrix(self):
For convenience, the heads and tails of each edge are saved in two
additional attributes start_nodes and end_nodes.
"""
if not hasattr(self, 'directed'):
self.is_directed()

if self.directed or not self.connected:
if self.is_directed() or not self.is_connected():
raise NotImplementedError('Focusing on connected non directed graphs first.')

start_nodes, end_nodes, weights = sparse.find(sparse.tril(self.W))

data = np.concatenate([np.ones(self.Ne/2), -np.ones(self.Ne/2)])
row = np.concatenate([np.arange(self.Ne/2), np.arange(self.Ne/2)])
data = np.concatenate([np.ones_like(start_nodes), -np.ones_like(end_nodes)])
row = np.concatenate([np.arange(len(start_nodes)), np.arange(len(end_nodes))])
col = np.concatenate([start_nodes, end_nodes])

self.B = sparse.coo_matrix((data, (row, col)),
shape=(self.Ne/2, self.N) ).tocsc()
shape=(len(start_nodes), self.N) ).tocsc()
self.Wb = sparse.diags(weights,0)
self.start_nodes = start_nodes
self.end_nodes = end_nodes
Expand Down
8 changes: 3 additions & 5 deletions pygsp/reduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ def kron_reduction(G, ind, threshold=np.spacing(1)):
"""
if isinstance(G, graphs.Graph):

if G.lap_type != 'combinatorial':
msg = 'Unknown reduction for {} Laplacian.'.format(G.lap_type)
raise NotImplementedError(msg)
Expand All @@ -353,14 +352,13 @@ def kron_reduction(G, ind, threshold=np.spacing(1)):
else:

L = G

N = np.shape(L)[0]
ind_comp = np.setdiff1d(np.arange(N, dtype=int), ind)

L_red = extract_submatrix(L,ind, ind)
L_in_out = extract_submatrix(L, ind, ind_comp)
L_red = utils.extract_submatrix(L,ind, ind)
L_in_out = utils.extract_submatrix(L, ind, ind_comp)
L_out_in = L_in_out.transpose().tocsc()
L_comp = extract_submatrix(L,ind_comp, ind_comp).tocsc()
L_comp = utils.extract_submatrix(L,ind_comp, ind_comp).tocsc()

Lnew = L_red - L_in_out.dot(utils.splu_inv_dot(L_comp, L_out_in))

Expand Down

0 comments on commit bf2183e

Please sign in to comment.