Skip to content

Instantly share code, notes, and snippets.

@prateekjoshi565
Created December 28, 2019 07:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prateekjoshi565/615b6d28f09c02e1fb8b7be8c8d23fae to your computer and use it in GitHub Desktop.
Save prateekjoshi565/615b6d28f09c02e1fb8b7be8c8d23fae to your computer and use it in GitHub Desktop.
# get unconnected node-pairs
all_unconnected_pairs = []
# traverse adjacency matrix
offset = 0
for i in tqdm(range(adj_G.shape[0])):
for j in range(offset,adj_G.shape[1]):
if i != j:
if nx.shortest_path_length(G, str(i), str(j)) <=2:
if adj_G[i,j] == 0:
all_unconnected_pairs.append([node_list[i],node_list[j]])
offset = offset + 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment