Reputation: 485
I have this GraphML file that I've read into Networkx.
So I access all the nodes by:
g.nodes()
It gives me a list of strings. Say one of them is "123". I then try to access a node as:
g["123"]
and it gives me a dictionary.
I then try to access the nodes using the nodes function as follows:
for n in g.nodes( data = True ):
print n
It then gives me a 2-tuple with the string node name as first element and a dictionary as a second element.
The thing is, it is a different dictionary from the first one. And it's confusing the heck out of me, so any help here is appreciated.
Are they supposed to be different? If so, why? If not, then what am I doing wrong? :) I can post the actual data if it would help.
Upvotes: 4
Views: 9162
Reputation: 526613
Have you considered reading the various pages of documentation?
nlist
: listA list of nodes. If data=True a list of two-tuples containing (node, node data dictionary).
and...
adj_dict
: dictionaryThe adjacency dictionary for nodes connected to n.
"Node data dictionary" and "adjacendy dictionary" are not the same thing.
Upvotes: 6