Cycles · Strongly Connected Components

Lesson 3

Nikolai Chukhin · Alexander S. Kulikov

The strongly connected components of this graph are the following: \[\{2, 8, 7\},\ \{4\},\ \{5, 6, 1, 3\}.\]

This is how they can be found in Python.

from networkx import DiGraph, strongly_connected_components

for scc in strongly_connected_components(DiGraph([
    '13', '61', '32', '27', '82', '43', '35', '63', '56', '78', '48'])):
    print(scc)

{'2', '8', '7'}
{'5', '6', '3', '1'}
{'4'}