DAG and topo

Kiosk tasks.

Kiosk tasks: unpack → restock → open. A DAG has no cycles. topological_sort is the order.

Goal

Print a valid task order.

import networkx as nx
G = nx.DiGraph()
G.add_edges_from([('unpack', 'restock'), ('restock', 'open'), ('count', 'open')])
print(list(nx.topological_sort(G)))
import networkx as nx
G = nx.DiGraph([('a', 'b'), ('b', 'c')])
print(nx.is_directed_acyclic_graph(G))
import networkx as nx
G = nx.DiGraph([('a', 'b'), ('b', 'a')])
print(nx.is_directed_acyclic_graph(G))
import networkx as nx
print(list(nx.lexicographical_topological_sort(nx.DiGraph([('b', 'c'), ('a', 'c')]))))