def test_scc_four_components(self): """ 1 -> 2 -> 4 | | . -> 3 -> . scc: [[4], [3], [2], [1]] """ graph = self.graph graph[1].neighbors.append(graph[2]) graph[2].neighbors.append(graph[4]) graph[1].neighbors.append(graph[3]) graph[3].neighbors.append(graph[4]) self.assertEqual(sccdg.scc(graph), [[4], [3], [2], [1]])
def test_scc_one_components(self): """ . <- - <- . | | 1 -> 2 -> 4 | | . -> 3 -> . scc: [[1,2,4,3] """ graph = self.graph graph[1].neighbors.append(graph[2]) graph[2].neighbors.append(graph[4]) graph[1].neighbors.append(graph[3]) graph[3].neighbors.append(graph[4]) graph[4].neighbors.append(graph[1]) self.assertEqual(sccdg.scc(graph), [[1,2,4,3]])