How To Access Node Attributes Without Key In Networkx?
please i need help for this : I need to access node attribute without key : I have this code : csv_F = csv.reader(open('MyFile.txt'),delimiter = '/') for line in csv_F: n
Solution 1:
Your trouble is here:
for nodex in G.nodes(data=True):
for b in (nodex[1]):
print(b, " --- ")
nodex[1]
is a dict containing all the attributes. When you iterate for b in D:
where D
is a dict you're iterating over the keys. So in your case you're printing out the key b
(which is 'myattribute'
), but I suspect you want nodex[1][b]
, which is the value.
Post a Comment for "How To Access Node Attributes Without Key In Networkx?"