Amir
Amir

Reputation: 1087

Visualize large graph with Networkx

I have a dataset in the form of node1, node2 and want to use networks to build a graph. It is fairly a large dataset which leads to a graph with 500k nodes

import pandas as pd
import numpy as np
import networkx as nx

df = pd.read_csv('large.csv')
G=nx.from_pandas_edgelist(df, 'node1','node2')

This part code runs very quickly which converts datafram into a graph. Then I tried to apply spring layout:

pos = nx.spring_layout(G)

This part of the code takes forever. If I try different layout like circular_layout or shell_layout it would be very quick but the layout is fir with my graph.

Is there a better way to apply spring_layout for such a large graph?

Upvotes: 5

Views: 9841

Answers (1)

Sparky05
Sparky05

Reputation: 4892

For that large graphs I would not recommend to use networkx for visualisation of such large graphs. Alternatives are graphviz or Gephi. Take a look at the following list of related questions:

Upvotes: 6

Related Questions