I created a graph in yEd and I want to check if an edge has an attribute. For example some edges have a label but some dont. When I try to do this I get an an error:
for n, nbrs in G.adjacency_iter():
for nbr,eattr in nbrs.items():
evpn = eattr['vpn']
elabel = eattr['label'] #error is here
if evpn != "No":
nlabel = G[n].get("label")
platform = G[n].get("platform")
if G[nbr].get("platform") == platform:
g_vpn.add_nodes_from([n,nbr], label, platform) # I dont know if this way
#to set attributes is right
While vpn attribute works because I have set a default value. I know I could just put a label value in all edges but I want my program to check if label is missing and setting a default value like what I do below. Although it doesn't work because it can't find the label attribute in some edges:
for e,v in G.edges():
if G[e][v].get("label") == ""
label = "".join("vedge",i)
i+=1
G[e][v]['label']=label
Also if you could check the rest of that code and tell me if it needs any improvement or make some things easier to do. Thanks