=== Problem M  depth-first search, and the back-edge test ===
v            A      B      C      D      E      F      G      H
d/f       1/10  11/12  13/16    2/9    3/6    7/8  14/15    4/5
clock stopped at 16 = 2|V| = 16
  A->D  tree
  B->D  cross
  B->E  cross
  C->G  tree
  D->E  tree
  D->F  tree
  E->H  tree
  F->H  cross
  G->H  cross
back edges: 0  -> the digraph IS a DAG

=== Problem N  topological sort by decreasing finishing time ===
  order: C(16) G(15) B(12) A(10) D(9) F(8) E(6) H(5)
  every arc points forward? yes

=== Problem O  topological sort by Kahn's in-degree algorithm ===
  initial in-degrees: A=0 B=0 C=0 D=2 E=2 F=1 G=1 H=3 
  round  emit  in-degrees after         queue after
      1     A  0 0 0 1 2 1 1 3        B C 
      2     B  0 0 0 0 1 1 1 3        C D 
      3     C  0 0 0 0 1 1 0 3        D G 
      4     D  0 0 0 0 0 0 0 3        G E F 
      5     G  0 0 0 0 0 0 0 2        E F 
      6     E  0 0 0 0 0 0 0 1        F 
      7     F  0 0 0 0 0 0 0 0        H 
      8     H  0 0 0 0 0 0 0 0        (empty)
  emitted 8 of 8 -> acyclic
  order: A B C D G E F H
  DFS order: C G B A D F E H
  positions on which the two orders agree: 1 of 8

=== Problem P  how many distinct topological orders? ===
  permutations checked: 40320
  legal topological orders: 84
  best legal order for a Hamiltonian path: A B D E C G F H
  it already contains 4 of its 7 links, so at least 3 extra prerequisites are needed to force a unique order

=== Problem Q  the critical path ===
  subject          weeks  earliest finish
  A ProgBasics        3               3
  B DiscreteMath      2               2
  C Calculus          4               4
  D DataStruct        5               8
  G Statistics        2               6
  E Algorithms        6              14
  F Databases         3              11
  H MachineLearn      4              18
  critical path (18 weeks): A -> D -> E -> H
  total of all eight subjects taken one at a time: 29 weeks

=== the trap: one extra prerequisite H -> A ===
  Kahn emits 3 of 8 -> the remaining 5 vertices lie on or after a cycle
  DFS finds 1 back edge(s) -> the same verdict, by a different route
