question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error converting graphs - cannot add edges, Invalid vertex id

See original GitHub issue

Describe 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:closed
  • Created 4 years ago
  • Comments:20 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
Yquetzalcommented, Oct 14, 2019

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 ?)

1reaction
oiwilliamcommented, Oct 14, 2019

Yes!!! \0/ \0/ You’ve solved it! CONGRATULATIONS! An issue really hard to find and you got it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot add edges, Invalid vertex ID in IGraph - Stack Overflow
So when you try to add edges, you're trying to add to vertices that do not exist.
Read more >
[igraph] add.edges error message
Error in add.edges(g2005, t(edges2005)) : At type_indexededgelist.c:240 : cannot add edges, Invalid vertex id. I'm not sure what this means.
Read more >
[Code]-python igraph cannot add edges-pandas - appsloveworld.com
I want to build a graph in Python via package igraph, I can add vertices, ... Error at type_indexededgelist.c:272: cannot add edges, Invalid...
Read more >
Tutorial — python-igraph v0.6 documentation
Every igraph Graph, vertex and edge behaves as a standard Python dictionary in some sense: you can add key-value pairs to any of...
Read more >
Chapter 9. Graph generators - igraph Reference Manual
If yes, then the first edge points from the first vertex ID in edges to ... Error code: IGRAPH_EINVEVECTOR : invalid edges vector...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found