I have a network of nodes created using python networkx. i want to store information in nodes such that i can access the information later based on the node label (the name of the node) and the field that in which the information has been stored (like node attributes). the information stored can be a string or a number I wish to do so in a manner such that if xyz is a node:
then I want to save two or three fields having strings like the date of birth of xyzdob=1185, the place of birth of xyzpob=usa, and the day of birth of xyzdayob=monday.
I know that i can use G.add_node has the attribute dictionary field in it...but I can't seem to access it for a particular field. if there is any other way i would appreciate it.
i then want to compare xyz with other nodes in the networks having the same information in common. i.e. intersection of node xyz with node abc based on date of bith, place of birth and day of birth
e.g for if nodes xyz and abc have an edge print their respective dobs, their pobs and their dayobs
回答1:
As you say, it's just a matter of adding the attributes when adding the nodes to the graph