from graphlib import TopologicalSorter
toposort = TopologicalSorter()
toposort.add(7,8,2)
toposort.add(9,5,6)
toposort.add(1,3,4)
toposort.prepare()
if toposort.is_active():
print("Progress can be made")
else:
print("Progress cannot be made")
Progress can be made
from graphlib import TopologicalSorter
toposort = TopologicalSorter()
toposort.add(3,2,4)
toposort.is_active()
Traceback (most recent call last):
File "C:\Users\findm\AppData\Local\Programs\Python\Python39\graphlib.py", line 8, in <module>
toposort.is_active()
File "C:\Users\findm\AppData\Local\Programs\Python\Python39\lib\graphlib.py", line 143, in is_active
raise ValueError("prepare() must be called first")
ValueError: prepare() must be called first
Comments