5

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?

1 Answer 1

6

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:

Sign up to request clarification or add additional context in comments.

1 Comment

some links are not working, can you please update the links of questions, Thankyou!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.