3

I have been using networkx for all my network graphing application so far; however, this new project requires graphs with 10^8 nodes in the graph and networkx was not built to handle this number of nodes (it becomes incredibly slow), so I switched to graph-tool which seems like it will be much faster.

In using graph-tool I would like to label each vertex in the graph with a user defined systematic label; so that I may look them up by label and not by index. I have tried going over the documentation, but there doesn't seem to be any support for this; property maps map from vertex_indices -> values, but I want the reverse.

Is there actual support for this that I am missing? Otherwise is my best option just to create a python dictionary and map labels to vertex_indices that way?

user2909415
  • 979
  • 3
  • 10
  • 26
  • Can you comment on what the problem was with networkx? I've used it with networks this size. It's a bit off your question topic, but what was the problem that was the bottleneck? – Joel Apr 15 '15 at 14:55
  • 2
    @Joel At around 10^6 nodes it was taking around 10 seconds for networkx to add one node and even more to add an edge (on a 2.4GHz 16-core cpu with 60G RAM machine). I couldn't understand why, until I read up on the documentation and some other posts, which seem to indicate that networkx is really only meant to be optimally used with up to 10^5 nodes. – user2909415 Apr 15 '15 at 14:59

1 Answers1

5

There is a find_vertex() function. However, it has a O(N) complexity. If you want O(1) lookups you have to construct your own dictionary, like you suggested.

Tiago Peixoto
  • 5,149
  • 2
  • 28
  • 28