Example #1
0
        internal static void CalculateCriticalPath <T, TResourceId, TActivity, TEvent>
            (this ArrowGraphBuilderBase <T, TResourceId, TActivity, TEvent> arrowGraphBuilder)
            where TActivity : IActivity <T, TResourceId>
            where TEvent : IEvent <T>
            where T : struct, IComparable <T>, IEquatable <T>
            where TResourceId : struct, IComparable <TResourceId>, IEquatable <TResourceId>
        {
            if (arrowGraphBuilder is null)
            {
                throw new ArgumentNullException(nameof(arrowGraphBuilder));
            }

            bool edgesCleaned = arrowGraphBuilder.CleanUpEdges();

            if (!edgesCleaned)
            {
                throw new InvalidOperationException(Properties.Resources.CannotPerformEdgeCleanUp);
            }

            arrowGraphBuilder.ClearCriticalPathVariables();

            if (!arrowGraphBuilder.CalculateEventEarliestFinishTimes())
            {
                throw new InvalidOperationException(Properties.Resources.CannotCalculateEventEarliestFinishTimes);
            }
            if (!arrowGraphBuilder.CalculateEventLatestFinishTimes())
            {
                throw new InvalidOperationException(Properties.Resources.CannotCalculateEventLatestFinishTimes);
            }
            if (!arrowGraphBuilder.CalculateCriticalPathVariables())
            {
                throw new InvalidOperationException(Properties.Resources.CannotCalculateCriticalPath);
            }
        }