Note And Edge Attributes
Adding node and edge attributees:
G=nx.Graph()
G.add_edge('A','B',weight=6,relation='family')
G.add_node('A',role = 'trader')
Accessing node attributes:
G.nodes() //list of all nodes
G.nodes(data=True) //list of all nodes with attributes
G.node['A']['role'] //role of A
out:['A','B']
[('A','role':'trader'),('B','role':'trader')
'trader'
Accessing Edge attributes:
G.edges(data=True) //list of all edges with attributes
G.edges(data='relation') //list of all edges with attribute 'relation'
G.edge['A']['B']['weight'] //weight of edge (A,B)
out:[('A','B',{'relation':'family','weight':'6'})]
[('A','B','family')]
6