Exemple #1
0
        public void BFS(Node pNode)
        {
            pNode.Visited = true;
            q.Enqueue(pNode);

            Node node;

            while (q.Count != 0)
            {
                node = q.Dequeue();
                Console.WriteLine(String.Format("node with data [{0}] visited", node.Data));

                NodeIterator iterator = node.Iterator;
                iterator.Reset();

                while (iterator.IsDone() == false)
                {
                    Node next_node = iterator.Next() as Node;

                    if (next_node.Visited == false)
                    {
                        next_node.Visited = true;
                        q.Enqueue(next_node);
                    }
                }
            }
        }
Exemple #2
0
        public void Reset(Node pNode)
        {
            pNode.Visited = false;

            NodeIterator iterator = pNode.Iterator;

            iterator.Reset();

            while (iterator.IsDone() == false)
            {
                Node node = iterator.Next() as Node;

                if (node.Visited == true)
                {
                    Reset(node);
                }
            }
        }
Exemple #3
0
        public void Deep(Node pNode)
        {
            pNode.Visited = true;
            Console.WriteLine(String.Format("node with data [{0}] visited", pNode.Data));
            //pNode.Print();

            NodeIterator iterator = pNode.Iterator;

            iterator.Reset();

            while (iterator.IsDone() == false)
            {
                Node node = iterator.Next() as Node;

                if (node.Visited == false)
                {
                    Deep(node);
                }
            }
        }
Exemple #4
0
 public Node(int pData)
 {
     Data     = pData;
     Links    = new List <Node>();
     Iterator = new NodeIterator(this);
 }