In the Sedgewick and Wayne implementation of the Bellman-Ford algorithm (https://algs4.cs.princeton.edu/44sp/BellmanFordSP.java) the method findNegativeCycle uses EdgeWeightedDirectedCycle (https://algs4.cs.princeton.edu/44sp/EdgeWeightedDirectedCycle.java) to find a directed cycle in the shortest path tree (the edges in the edgeTo array).
Also, in the check method, it is asserted that the weight of this directed cycle is negative. Thus, if Java assertions are enabled, the BellmanFordSP constructor will throw an exception if the negativeCycle method returns a cycle whose weight is not negative.
Question: if the shortest path tree contains both a zero-weight cycle and a negative-weight cycle, what makes sure that EdgeWeightedDirectedCycle doesn't return the zero-weight cycle (thus causing an assertion failure)?
