[Python] Visualize large graph with Networkx

Discussão em 'Python' iniciado por Stack, Março 19, 2025.

  1. Stack

    Stack Membro Participativo

    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?

    Continue reading...

Compartilhe esta Página