简体   繁体   English

使用python从.csv文件读取边缘到igraph

[英]Read edges from .csv file to igraph using python

Let's say I have a .csv file containing the following: 假设我有一个包含以下内容的.csv文件:

Apple    Banana
Apple    Coconut
Banana   Coconut
Coconut  Apple

And these should mean directed edges between two nodes, like: Apple->Banana, Apple->Coconut, etc. 这些应该意味着两个节点之间的有向边,例如:Apple-> Banana,Apple-> Coconut等。

What is the proper method to use this kind of input in igraph? 在igraph中使用这种输入的正确方法是什么?

This is what the Read_Ncol(f, names=True, weights="if_present", directed=True) function exactly does. 这就是Read_Ncol(f, names=True, weights="if_present", directed=True)函数的确如此。

http://igraph.org/python/doc/igraph-pysrc.html#GraphBase.Read_Ncol http://igraph.org/python/doc/igraph-pysrc.html#GraphBase.Read_Ncol

>>> from igraph import *
>>> g = Graph.Read_Ncol("stuff.csv", directed=True)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM