Networkx Strongly Connected Components for Undirected Graphs

1,761 views
Skip to first unread message

Ayushi Dalmia

unread,
Mar 20, 2016, 4:28:28 PM3/20/16
to networkx-discuss
Hi,

I am running the following piece of code on Networkx 1.6 and Networkx 1.11

import networkx as nx
G = nx.Graph()
G.add_edges_from([(1,2),(1,3)])
nx.strongly_connected_components((G))

The code runs fine on version 1.6 but raises an exception as: networkx.exception.NetworkXNotImplemented: not implemented for undirected type

How can I fix this? 

Thanks and regards,
Ayushi



Aric Hagberg

unread,
Mar 20, 2016, 4:29:57 PM3/20/16
to networkx...@googlegroups.com
Since you have an undirected graph you should use nx.connected_components(G).
The algorithm in nx.strongly_connected_components is for directed graphs.

Aric
> --
> You received this message because you are subscribed to the Google Groups
> "networkx-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to networkx-discu...@googlegroups.com.
> To post to this group, send email to networkx...@googlegroups.com.
> Visit this group at https://groups.google.com/group/networkx-discuss.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages