synchronized Weight getMaximumFinish ( ) { if ( calcMaxFinish == null ) { // Find the longest distance from time zero to a finish. Weight result = WeightFactory . NEG_INFINITY ; if ( shortestDistancesFromTimeZeroSource == null ) { shortestDistancesFromTimeZeroSource = BellmanFord . calcShortestDistances ( timeZero , directedGraph , BellmanFord . Mode . SOURCE ) ; if ( shortestDistancesFromTimeZeroSource == null ) { throw new IllegalStateException ( "Negative cycle detected!" ) ; } } for ( int i = 0 , n = intervals . size ( ) ; i < n ; i ++ ) { Object finish = intervals . get ( i ) . getFinish ( ) ; result = Weight . max ( result , ( Weight ) shortestDistancesFromTimeZeroSource . get ( finish ) ) ; } calcMaxFinish = result ; } return calcMaxFinish ; }
Calculates and returns the maximum path from time zero to the finish of an interval .