/// <summary>
        /// The method that controls the creation of the history graph.
        /// </summary>
        public StoryGraph CreateStoryGraph(StoryNode rootNode)
        {
            // We clone the root into a separate variable.
            StoryNode originRoot = (StoryNode)rootNode.Clone();

            // We continue to work until at least one target state is reached.
            while (!reachedGoalState)
            {
                // We create a new graph by starting to expand the root.
                BFSTraversing(newStoryGraph.GetRoot());

                // We go through the created graph, looking for target states in it.
                BFSGoalAchieveControl(newStoryGraph.GetRoot());

                // If it was not possible to find even one target state in the constructed graph.
                if (!reachedGoalState || newStoryGraph.GetNodes().Count > maxNodes)
                {
                    graphСonstructor.CreateGraph(newStoryGraph, @"D:\Graphviz\bin\newStoryGraph.dt");

                    // Then we clear the graph, and all the links added to the root.
                    newStoryGraph = new StoryGraph();
                    originRoot.GetEdges().Clear();
                    originRoot.GetLinks().Clear();

                    // After that, we reassign to the previously cleared column an indication of the root.
                    newStoryGraph.SetRoot((StoryNode)originRoot.Clone());

                    reachedGoalState = false;
                }
            }

            // We return a graph that is guaranteed to have at least one target state.
            return(newStoryGraph);
        }
 public void ClearLowerNode()
 {
     if (lowerNode != null)
     {
         lowerNode.GetEdges().Remove(this);
         lowerNode = null;
     }
 }
示例#3
0
        public void DeleteTestNode(ref StoryNode testNode)
        {
            foreach (var edge in testNode.GetEdges().ToList())
            {
                edge.GetUpperNode().RemoveEdge(edge);
                edge.GetLowerNode().RemoveEdge(edge);
                edge.ClearEdge();
            }

            foreach (var link in testNode.GetLinks().ToList())
            {
                testNode.DeleteLink(link);
            }
        }
示例#4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="firstNode">Current node</param>
        /// <param name="secondNode">New node</param>
        public void ConnectionTwoNodes(PlanAction action, StoryNode firstNode, StoryNode secondNode, bool duplicate)
        {
            Edge newEdge = new Edge();

            newEdge.SetAction(action);

            newEdge.SetUpperNode(ref firstNode);
            newEdge.SetLowerNode(ref secondNode);

            firstNode.AddEdge(newEdge);
            secondNode.AddEdge(newEdge);

            firstNode.AddLinkToNode(ref secondNode);
            secondNode.AddLinkToNode(ref firstNode);

            if (firstNode.GetEdges().Count != firstNode.GetLinks().Count)
            {
                bool test = true;
            }
        }
 public void ClearUpperNode()
 {
     upperNode.GetEdges().Remove(this);
     upperNode = null;
 }