[数据结构][Python]DAG有向无环图和拓扑排序
def topsort(G): count = dict((u,0) for u in G) for u in G: for v in G[u]: count[v] +=1 Q = [u for u in G if count[u] == 0] S = [] while Q: u = Q.pop() ...