Storing and Accessing node attributes python networkx
As you say, it’s just a matter of adding the attributes when adding the nodes to the graph G.add_node(‘abc’, dob=1185, pob=’usa’, dayob=’monday’) or as a dictionary G.add_node(‘abc’, {‘dob’: 1185, ‘pob’: ‘usa’, ‘dayob’: ‘monday’}) To access the attributes, just access them as you would with any dictionary G.node[‘abc’][‘dob’] # 1185 G.node[‘abc’][‘pob’] # usa G.node[‘abc’][‘dayob’] # monday … Read more