private static Schedule CreateScheduleGraphWithOuterAndInnerLoop(
            ScheduleConditionInformation outerLoopConditionInfo,
            ScheduleConditionInformation innerLoopConditionInfo,
            ScheduleActionInformation outerLoopInfo,
            ScheduleActionInformation innerLoopInfo)
        {
            var graph = new BidirectionalGraph<IScheduleVertex, ScheduleEdge>();
            var start = new StartVertex(1);
            graph.AddVertex(start);

            var end = new EndVertex(2);
            graph.AddVertex(end);

            var vertex1 = new InsertVertex(3);
            graph.AddVertex(vertex1);

            var vertex2 = new InsertVertex(4);
            graph.AddVertex(vertex2);

            var vertex3 = new ExecutingActionVertex(5, outerLoopInfo.Id);
            graph.AddVertex(vertex3);

            var vertex4 = new InsertVertex(6);
            graph.AddVertex(vertex4);

            var vertex5 = new ExecutingActionVertex(7, innerLoopInfo.Id);
            graph.AddVertex(vertex5);

            graph.AddEdge(new ScheduleEdge(start, vertex1));
            graph.AddEdge(new ScheduleEdge(vertex1, vertex2));

            graph.AddEdge(new ScheduleEdge(vertex2, end, outerLoopConditionInfo.Id));
            graph.AddEdge(new ScheduleEdge(vertex2, vertex3));

            graph.AddEdge(new ScheduleEdge(vertex3, vertex1, innerLoopConditionInfo.Id));
            graph.AddEdge(new ScheduleEdge(vertex3, vertex4));

            graph.AddEdge(new ScheduleEdge(vertex4, vertex5));
            graph.AddEdge(new ScheduleEdge(vertex5, vertex3));

            return new Schedule(graph, start, end);
        }
        /// <summary>
        /// Replaces the action current stored against the given ID with a new one.
        /// </summary>
        /// <param name="actionToReplace">The ID of the action that should be replaced.</param>
        /// <param name="newAction">The new action.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="actionToReplace"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="newAction"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="UnknownScheduleActionException">
        ///     Thrown if <paramref name="actionToReplace"/> is not linked to a known action.
        /// </exception>
        public void Update(
            ScheduleElementId actionToReplace,
            IScheduleAction newAction)
        {
            {
                Lokad.Enforce.Argument(() => actionToReplace);
                Lokad.Enforce.Argument(() => newAction);
                Lokad.Enforce.With<UnknownScheduleActionException>(
                    m_Actions.ContainsKey(actionToReplace),
                    Resources.Exceptions_Messages_UnknownScheduleAction);
            }

            var oldInfo = m_Actions[actionToReplace].Information;
            var info = new ScheduleActionInformation(
                actionToReplace,
                oldInfo.Name,
                oldInfo.Description);
            m_Actions[actionToReplace] = new ActionMap(info, newAction);
        }
            /// <summary>
            /// Initializes a new instance of the <see cref="ActionMap"/> class.
            /// </summary>
            /// <param name="information">The information describing the action.</param>
            /// <param name="action">The action.</param>
            public ActionMap(ScheduleActionInformation information, IScheduleAction action)
            {
                {
                    Debug.Assert(information != null, "The action information should not be a null reference.");
                    Debug.Assert(action != null, "The action should not be a null reference.");
                }

                m_Info = information;
                m_Action = action;
            }
        /// <summary>
        /// Adds the <see cref="IScheduleAction"/> object with the variables it affects and the dependencies for that action.
        /// </summary>
        /// <param name="action">The action that should be stored.</param>
        /// <param name="name">The name of the action that is being described by this information object.</param>
        /// <param name="description">The description of the action that is being described by this information object.</param>
        /// <returns>An object identifying and describing the action.</returns>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="action"/> is <see langword="null" />.
        /// </exception>
        public ScheduleActionInformation Add(
            IScheduleAction action,
            string name,
            string description)
        {
            {
                Lokad.Enforce.Argument(() => action);
            }

            var id = new ScheduleElementId();
            var info = new ScheduleActionInformation(id, name, description);
            m_Actions.Add(id, new ActionMap(info, action));

            return info;
        }