i generate a complete graph with arbitrary nodes. each edge has two attributes which the second one is the function of the first one. (for example when the first one is x, the second one is 1/x)
how can i add these attributes to edges.
def create_random_topology(size):
G = nx.generators.complete_graph(size)
attfirst={x:random.randint(100,500) for x in G.edges()}
nx.set_edge_attributes(G, name="PR", values=attfirst)
#attsecond= 1/attfirst
i want to have this graph e.g {(0,1):{PR= 10 , BW=1/10}, (0,2):{PR=5 , BW=1/5}, (1,2):{PR=2 , BW=1/2)}}
because of the graph has the variable size, i wont access to the edge with the exact name of it’s node (for example (1,2)).
Sudabeh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.