Hi Folk
I always use the below piece of code to compute the similarity matrix. This time I am getting an error. This is the piece of code:
import networkx as nx
import numpy, matplotlib
from scipy.cluster import hierarchy
from scipy.spatial import distance
G = nx.karate_club_graph()
n = len(G.nodes())
path_length = nx.all_pairs_shortest_path_length(G)
distances = numpy.zeros((n,n))
for u,p in path_length.iteritems():
for v,d in p.iteritems():
distances[int(u)-1][int(v)-1] = d
and this the error message:
AttributeError Traceback (most recent call last)
/var/folders/31/w56d47t956zfp0kklgtz_yq40000gn/T/ipykernel_50535/4052642967.py in <module>
9 distances = numpy.zeros((n,n))
10
---> 11 for u,p in path_length.iteritems():
12 for v,d in p.iteritems():
13 distances[int(u)-1][int(v)-1] = d
AttributeError: 'generator' object has no attribute 'iteritems'
I am having the same error message when replacing iteritems by items.
Is there a new way to access those items?
Best
F