tails[h].append(t)
ordered = [h for h in tails if h not in num_heads]
for h in ordered:
    for t in tails[h]:
        num_heads[t] -= 1
if not num_heads[t]:
    ordered.append(t)
cyclic = [n for n, heads in num_heads.items() if heads]
return ordered, cyclic
if __name__ == '__main__':
    connections = [(3, 7), (6, 5), (4, 6), (5, 3), (7, 8), (1, 2), (2, 1)]
print(topological_sort(connections))
Как я могу заказать список подключений