0

As I understand connected_components() method in NetworkX should generate components in a given undirected graph (There are strongly_connected_components() and weakly_connected_components() for directed graph). I have generated an undirected graph G and while trying to implement networkx.connected_components(G), I am getting the error NetworkXNotImplemented: not implemented for directed type.

Note: G was the interaction network of users of the Pretty Good Privacy (PGP) algorithm (http://deim.urv.cat/~aarenas/data/welcome.htm). The network is a single giant component.

I have implemented the method for many other undirected networks.

import networkx as nx

G=nx.read_pajek("PGPgiantcompo.net")
C=max(nx.connected_components(G), key=len)

Expected result:

C contains the giant component which is G itself.

Actual result:


NetworkXNotImplemented                    Traceback (most recent call last)
<ipython-input-1-27a0ad1fa789> in <module>()

---> 27 C=max(nx.connected_components(G), key=len)
     28 Giant_frozen=G.subgraph(C)
     29 nx.draw(Giant_frozen, with_labels=True, font_weight='bold')

<decorator-gen-295> in connected_components(G)

F:\Anaconda3\lib\site-packages\networkx\utils\decorators.py in _not_implemented_for(not_implement_for_func, *args, **kwargs)
     78         if match:
     79             msg = 'not implemented for %s type' % ' '.join(graph_types)
---> 80             raise nx.NetworkXNotImplemented(msg)
     81         else:
     82             return not_implement_for_func(*args, **kwargs)

NetworkXNotImplemented: not implemented for directed type
mohammed wazeem
  • 1,310
  • 1
  • 10
  • 26
Divya Lekha
  • 171
  • 5
  • Take a look at type(G) and report the results. It's possible read_pajek is unable to correctly guess the type (directed v undirected). – Aric Aug 31 '19 at 18:30
  • Yeah.. G was multiedged. Solved by converting G to undirected. Thanks – Divya Lekha Sep 01 '19 at 00:12

0 Answers0