I have a large undirected weighted graph with ~375,000 nodes and ~3,400,000 edges represented as adjacency list (dictionary of dictionaries).
e.g.
A --> (B,2), (C,4)
B --> (A,2)
C --> (A,4)
is represented as
{A : {B : 2, C : 4}, B : {A : 2}, C : {A : 4}}
I want to convert this graph to python-igraph graph and subsequently run walktrap community detection algorithm. I have tried following approach:
g = igraph.Graph()
for node in mygrpah.keys():
g.add_vertex(name=node) # each node is a string
for node,neighbours in mygraph.iteritems():
g.add_edges([(node,neighbour) for neighbour in neighbours.keys()])
for neighbour in neighbours.keys():
# to avoid adding edge while traversing neighbour's dictionary
del mygraph[neighbour][node]
I tested this on a subgraph with 150,000 nodes and it took ~11 hours on my computer with 4GB RAM and i5-4200U CPU @ 1.60GHz × 4 processor.
- is there a better approach to do the conversion?
- is there any other graph library which is faster and provides support for walktrap community detection algorithm?