Extraindo a componente gigante de um grafo com Python + Networkx

São quatro passos mínimos:

  • Importando a biblioteca:
    import networkx as nx
  • Ler o arquivo com a lista de ligações (edge list)
    G=nx.read_edgelist('arquivo.dat')
  • Quebrar as componentes conectadas
    sG=nx.connected_component_subgraphs(G)
  • Salvar a componente gigante, é o primeiro grafo da lista sG
    nx.write_edgelist(sG[0],'saida.dat')

Apenas isso, e o grafo está separado.

Linkbacks

Use the following URL for manually sending trackbacks: http://complex.if.uff.br/lib/plugins/linkback/exe/trackback.php/orahcio:home:componente-principal

Discussão

Enter your comment
KAISD
 
orahcio/home/componente-principal.txt · Última modificação: 2010/10/14 18:47 (edição externa)
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0