I have a data in csv file and that has following datas in it:
Origin Destiny Hours
0 Alat Baku 1.08
1 Baku Alat 1.13
2 Alat Shirvan 0.83
3 Shirvan Alat 0.80
4 Imishli Shirvan 1.42
Index(['Origin', 'Destiny', 'Hours'], dtype='object')
Now when i do
G = networkx.from_pandas_edgelist(data, source='Origin', target='Destiny', edge_attr=True)
there happens a problem or a misunderstanding for me: Because both G.edges["Baku","Alat"]
and G.edges["Alat","Baku"]
gives the same result which is {'Hours': 1.13}
. Why is it like this,as it should give 1.08 and 1.13 for reversed order.
You should use Directed graphs by using parameter create_using=networkx.DiGraph()
G = networkx.from_pandas_edgelist(
data, source='Origin', target='Destiny', edge_attr=True,
create_using=networkx.DiGraph())
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.