Skip to content

Commit

Permalink
fix a bug from nx.from_scipy_sparse_matrix that treats target link (0…
Browse files Browse the repository at this point in the history
…,1) as zero-weight edge
  • Loading branch information
muhanzhang committed Mar 26, 2019
1 parent fed6993 commit 886de41
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Python/util_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@ def subgraph_extraction_labeling(ind, A, h=1, max_nodes_per_hop=None, node_infor
nodes.remove(ind[1])
nodes = [ind[0], ind[1]] + list(nodes)
subgraph = A[nodes, :][:, nodes]
# remove link between target nodes
subgraph[0, 1] = 0
subgraph[1, 0] = 0
# apply node-labeling
labels = node_label(subgraph)
# get node features
Expand All @@ -120,6 +117,9 @@ def subgraph_extraction_labeling(ind, A, h=1, max_nodes_per_hop=None, node_infor
features = node_information[nodes]
# construct nx graph
g = nx.from_scipy_sparse_matrix(subgraph)
# remove link between target nodes
if g.has_edge(0, 1):
g.remove_edge(0, 1)
return g, labels.tolist(), features


Expand Down

0 comments on commit 886de41

Please sign in to comment.