Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/302.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在python中将edgelist导入igraph的格式_Python_Social Networking_Igraph_Sna - Fatal编程技术网

在python中将edgelist导入igraph的格式

在python中将edgelist导入igraph的格式,python,social-networking,igraph,sna,Python,Social Networking,Igraph,Sna,igraph为导入python而接受的edgelist格式是什么?包含加权边的文本文件应该是什么样子 我以前在R中使用过igraph,但在我需要使用的机器上没有一个正常工作的R安装,所以我被python困住了 我有一个类似这样的egelist.txt文件: 123123, 321321, 1 222222, 333333, 2 123123, 333333, 3 222222, 321321, 4 …其中值为(源、目标、权重)形式 我将如何在python中导入它?或者我应该重新格式化我的输入

igraph为导入python而接受的edgelist格式是什么?包含加权边的文本文件应该是什么样子

我以前在R中使用过igraph,但在我需要使用的机器上没有一个正常工作的R安装,所以我被python困住了

我有一个类似这样的egelist.txt文件:

123123, 321321, 1
222222, 333333, 2
123123, 333333, 3
222222, 321321, 4
…其中值为(源、目标、权重)形式

我将如何在python中导入它?或者我应该重新格式化我的输入

我正在尝试

import igraph

g = igraph.Graph.Read_Edgelist()

我不知道如何设置如何告诉import语句我的列的顺序是什么,以及我对文档的理解(http://hal.elte.hu/~nepusz/development/igraph/tutorial/tutorial.html)是假设我有321个节点,而不是“321”作为节点的标记ID。

清除文件中的所有逗号(即仅使用空格作为分隔符),然后使用
图形。读取\u Ncol
。这应该能奏效。文件中的数字ID将分配给
name
vertex属性,边权重将存储在
weight
edge属性中。

看起来,如果文件是以制表符分隔而不是逗号分隔的,那么它将是一个用图形读取的文件。read\u Ncol()。