コード例 #1
0
ファイル: Relation.cs プロジェクト: GarageInc/all
        // recursive path
        public static void start(ref Node startNode, Node current, ref Node end,   Path tmpPath)
        {
            tmpPath.Add(current);

            current.isVisited = true;

            bool stepBack = false;           

            if (current != end)
            {
                for(int i = current.visitedCounter; i < current.relations.Count ; i++)
                {
                    current.visitedCounter++;

                    if ( !current.relations[i].leftNode.isVisited )
                    {
                        start(ref startNode, current.relations[i].leftNode, ref end, tmpPath);
                        return;
                    }
                    else if ( !current.relations[i].rightNode.isVisited)
                    {
                        start(ref startNode, current.relations[i].rightNode, ref end, tmpPath);
                        return;
                    }// pass
                }

                // trace( "\nТупик: ", current.ToString() );
                
                if ( current.visitedCounter == current.relations.Count && current == startNode)
                {
                    stepBack = false;
                } else
                {
                    stepBack = true;
                }

            }
            else
            {
                trace("\n", tmpPath);

                stepBack = true;                
            }

            if ( stepBack )
            {
                Node newStartNode = null;

                if ( tmpPath.nodes.Count >= 2 )
                {
                    tmpPath.nodes.RemoveAt(tmpPath.nodes.Count - 1);

                    current.visitedCounter = 0;
                    current.isVisited = false;

                    newStartNode = tmpPath.nodes.Last();
                } else
                {
                    newStartNode = current;
                }
                
                tmpPath.nodes.RemoveAt(tmpPath.nodes.Count - 1);// because than added in start

                start(ref startNode, newStartNode, ref end, tmpPath);
                return;

            }// pass

        }
コード例 #2
0
ファイル: Program.cs プロジェクト: GarageInc/all
 public static void change(Node node)
 {
     node.rootWord = "3";
 }
コード例 #3
0
ファイル: Relation.cs プロジェクト: GarageInc/all
 public Relation(Node l, Node r)
 {
     leftNode = l;
     rightNode = r;
 }
コード例 #4
0
ファイル: Path.cs プロジェクト: GarageInc/all
 public void Add(Node node)
 {
     this.nodes.Add(node);
 }