Skip to content

Commit bf2183e

Browse files
committed
Fixes update issues
1 parent c1d75ba commit bf2183e

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

pygsp/graphs/graph.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -568,20 +568,17 @@ def create_incidence_matrix(self):
568568
For convenience, the heads and tails of each edge are saved in two
569569
additional attributes start_nodes and end_nodes.
570570
"""
571-
if not hasattr(self, 'directed'):
572-
self.is_directed()
573-
574-
if self.directed or not self.connected:
571+
if self.is_directed() or not self.is_connected():
575572
raise NotImplementedError('Focusing on connected non directed graphs first.')
576573

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

579-
data = np.concatenate([np.ones(self.Ne/2), -np.ones(self.Ne/2)])
580-
row = np.concatenate([np.arange(self.Ne/2), np.arange(self.Ne/2)])
576+
data = np.concatenate([np.ones_like(start_nodes), -np.ones_like(end_nodes)])
577+
row = np.concatenate([np.arange(len(start_nodes)), np.arange(len(end_nodes))])
581578
col = np.concatenate([start_nodes, end_nodes])
582579

583580
self.B = sparse.coo_matrix((data, (row, col)),
584-
shape=(self.Ne/2, self.N) ).tocsc()
581+
shape=(len(start_nodes), self.N) ).tocsc()
585582
self.Wb = sparse.diags(weights,0)
586583
self.start_nodes = start_nodes
587584
self.end_nodes = end_nodes

pygsp/reduction.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,6 @@ def kron_reduction(G, ind, threshold=np.spacing(1)):
339339
340340
"""
341341
if isinstance(G, graphs.Graph):
342-
343342
if G.lap_type != 'combinatorial':
344343
msg = 'Unknown reduction for {} Laplacian.'.format(G.lap_type)
345344
raise NotImplementedError(msg)
@@ -353,14 +352,13 @@ def kron_reduction(G, ind, threshold=np.spacing(1)):
353352
else:
354353

355354
L = G
356-
357355
N = np.shape(L)[0]
358356
ind_comp = np.setdiff1d(np.arange(N, dtype=int), ind)
359357

360-
L_red = extract_submatrix(L,ind, ind)
361-
L_in_out = extract_submatrix(L, ind, ind_comp)
358+
L_red = utils.extract_submatrix(L,ind, ind)
359+
L_in_out = utils.extract_submatrix(L, ind, ind_comp)
362360
L_out_in = L_in_out.transpose().tocsc()
363-
L_comp = extract_submatrix(L,ind_comp, ind_comp).tocsc()
361+
L_comp = utils.extract_submatrix(L,ind_comp, ind_comp).tocsc()
364362

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

0 commit comments

Comments
 (0)