python - How to get the edge between two nodes? -


i want edge between 2 nodes in networkx graph. more specifically, want data associated edge. know a priori these 2 nodes linked. there function this?

the edge data stored in dictionary. access dictionary, use get_edge_data().

import networkx nx g=nx.graph() g.add_edge(1,2, weight=5) g.get_edge_data(1,2) > {'weight': 5} 

if want iterate through edges can use g.edges(data=true)

h = nx.graph() h.add_edge(2, 3, color = 'red') h.add_edge(1, 2, weight = 4) u,v,data in h.edges_iter(data=true):     print u, v, data > 1 2 {'weight': 4} > 2 3 {'color': 'red'} 

Comments

Popular posts from this blog

android - net_scheduler holding wakelock -

sql - MySQL : Getting Entries from a many-to-many table -

java - Retrieving data from database using jsp (Hibernate + Spring + Maven) -