简体   繁体   English

如何从边缘列表创建python-igraph图

[英]How to create a python-igraph Graph from edge list

I have a vertices list as (vertexID) and a edge list as (srcID, dstID). 我有一个顶点列表为(vertexID)和一个边缘列表为(srcID,dstID)。 I want to create a igraph Graph out of these nodes and edges. 我想从这些节点和边缘创建一个igraph图。 The ids are OSM Node IDs and they do not start from zero and are not sequential in most cases. 这些ID是OSM节点ID,并且它们不是从零开始并且在大多数情况下不是顺序的。 Also, I am dealing with hundreds and thousands of nodes. 另外,我正在处理成千上万个节点。 Hence to make the graph creation fast I tried following code: 因此,为了快速创建图形,我尝试了以下代码:

gr = Graph()
gr.add_vertices(vertexList)
gr.add_edges(edgeList)

But I get following error: 但是我得到以下错误:

OverflowError: long integer too large for conversion to C int

I think because my Ids are of type long I get this error. 我认为因为我的Id属于长类型,所以会出现此错误。 Is there any way to get around this error without sacrificing the speed of graph creation? 在不牺牲图形创建速度的情况下,有什么方法可以解决此错误?

刚才有同样的问题-我将列表转换成字符串,整数,然后问题解决了-尽管我还没有创建另一个问题。

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

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