zoukankan      html  css  js  c++  java
  • 拓扑排序

     1 void toposort() {
     2     int h = t = 0;
     3     for (int i = 1; i <= n; i++) {
     4         if (in[i] == 0) {
     5             q[t++] = i;
     6         }
     7     }
     8     while (h != t) {
     9         k = q[h++];
    10         for (int i = h[k]; i; i = e[i].n) {
    11             if (!--in[e[i].t]) {
    12                 q[t++] = e[i].t;
    13             }
    14         }
    15     }
    16 }
  • 相关阅读:
    Day60
    Day53
    Day50
    Day49
    Day48
    Day47
    Day46(2)
    Day46(1)
    Day45
    Day44
  • 原文地址:https://www.cnblogs.com/Accpted/p/11203322.html
Copyright © 2011-2022 走看看