Monday 15 July 2013

How to check if an edge has an attribute in Networkx -


I created a graph in yEd and I want to know that there is a feature of the edge, for example on some edges one The label is but nothing. When I try to do this, I get an error: For G, live for NBR Adjensi_Iter (): For NBR, eattr in NBR. ITEMS (): evpn = eattr ['vpn' LLBL = AATT ['label'] #Arpn is here if EPPN! = "No": NLLL = G [n] .gate ("label") platform = g [n] .gate ("forum") if g [nbr] .get ("forum") == forum: g_vpn.add_nodes_from ([N, nbr], label, stage) # I do not know that this kind of # attributes is correct to set

While VPN feature works because I set a default value Have done I know that I could have just put one label value in all the edges, but I want to set a default value to know what my label is not, and what I have to do below. Although it does not work because it can not attribute the label attribute in some edges:

  For E, V.G. In (): If G [E] [V]. ("Label") == "" label = "" .joined ("wage", i) i + = 1g [e] [v] ['label'] = label   

In addition to this, if you can check the rest of the code and tell me that it needs any improvement or some things are easy to do. Thanks

The attributes of the edges are stored as a dictionary so that you can check whether the key In the dictionary:

  in [1]: Import Networks in NX [2]: in G = nx.Graph () [3]: g.ad_age (1,2, color = In 'blue' [4]: ​​in G.AD_age (2,3) [5]: 'color' j [1] [2] outside [5]: truthfully [6]: 'color' in ji [ 2] [3] out [6]: Incorrect    

No comments:

Post a Comment