Error converting graphs - cannot add edges, Invalid vertex id
See original GitHub issueDescribe the bug I have received the “InternalError: Error at type_indexededgelist.c:272: cannot add edges, Invalid vertex id” error trying to use the method algorithms.angel. I have a nx undirected weighted graph, created from a pandas data frame, and think that the error is in __from_nx_to_igraph at utils.py
To Reproduce
my graph:
g = nx.from_pandas_edgelist(df, 'source', 'target', 'weight')
When I try to see my edges:
list(g.edges())
I receive:
[(21198069, 28883519), (21198069, 28667573), (21198069, 26440037), ... ]
To see the weight of an edge:
g.edges[21198069, 28883519]
Output:
{'weight': 9}
When I try to get the communities with the command: coms = algorithms.angel(g, min_community_size=4, threshold=0.25)
I get the error:
InternalError Traceback (most recent call last)
<ipython-input-132-44b171f02346> in <module>
1 #coms = algorithms.big_clam(g, 5)
----> 2 coms = algorithms.angel(g, min_community_size=4, threshold=0.25)
/opt/conda/lib/python3.6/site-packages/cdlib/algorithms/overlapping_partition.py in angel(g, threshold, min_community_size)
120 raise ModuleNotFoundError("Optional dependency not satisfied: install igraph to use the selected feature.")
121
--> 122 g = convert_graph_formats(g, ig.Graph)
123 with suppress_stdout():
124 a = Angel(graph=g, min_comsize=min_community_size, threshold=threshold, save=False)
/opt/conda/lib/python3.6/site-packages/cdlib/utils.py in convert_graph_formats(graph, desired_format, directed)
122 return __from_igraph_to_nx(graph, directed)
123 elif ig is not None and desired_format is ig.Graph:
--> 124 return __from_nx_to_igraph(graph, directed)
125 else:
126 raise TypeError("The graph object should be either a networkx or an igraph one.")
/opt/conda/lib/python3.6/site-packages/cdlib/utils.py in __from_nx_to_igraph(g, directed)
79 gi = ig.Graph(directed=directed)
80 gi.add_vertices(list(g.nodes()))
---> 81 gi.add_edges(list(g.edges()))
82 return gi
83
/opt/conda/lib/python3.6/site-packages/igraph/__init__.py in add_edges(self, es)
253 endpoints. Vertices are enumerated from zero.
254 """
--> 255 return GraphBase.add_edges(self, es)
256
257 def add_vertex(self, name=None, kwds):
InternalError: Error at type_indexededgelist.c:272: cannot add edges, Invalid vertex id
- CDlib version cdlib-0.1.7
- Operating System mac os 10.12.5
- Python version 3.6
- Version(s) of CDlib required libraries
Additional context I’m using jupyter notebook
Issue Analytics
- State:
- Created 4 years ago
- Comments:20 (7 by maintainers)
Top GitHub Comments
Got it! (I think) Playing around with a colab notebook I realized that you need to reload the cdlib library after installing angel, because a variable is set at None in cdlib for Angel if it is not available when you import it. So you would only have to restart your notebook kernel, or, in your docker installation process, to install angel before importing cdlib. It that is the explanation, we could solve the problem by checking if the library can be imported again at each angel run… (Giulio, would it break something else ?)
Yes!!! \0/ \0/ You’ve solved it! CONGRATULATIONS! An issue really hard to find and you got it.