コード例 #1
0
ファイル: BFS.cs プロジェクト: pbasappa/Foundation
    public static void BFSearch(Graph graph, int search)
    {
        AdjacencyListNode graphTracker = new AdjacencyListNode();

        graphTracker = graph.start;

        while (graphTracker != null)
        {
            Node listTracker = new Node();
            listTracker = graphTracker.list.head;

            while (listTracker != null)
            {
                if (listTracker.value != search)
                {
                    listTracker = listTracker.next;
                }
                else
                {
                    Console.WriteLine("Found");
                    return;
                }
            }

            graphTracker = graphTracker.next;
        }

        Console.WriteLine("Not Found");
        return;
    }
コード例 #2
0
ファイル: BFS.cs プロジェクト: pbasappa/Foundation
        public void Add(List list)
        {
            AdjacencyListNode temp = new AdjacencyListNode();

            temp.list = list;

            if (this.start == null)
            {
                this.start = temp;
                this.end   = temp;
            }
            else
            {
                this.end.next = temp;
                this.end      = temp;
            }
        }
コード例 #3
0
ファイル: BFS.cs プロジェクト: pbasappa/Foundation
        public void PrintGraph()
        {
            AdjacencyListNode tracker = new AdjacencyListNode();

            tracker = this.start;

            while (tracker != null)
            {
                Node listTracker = new Node();
                listTracker = tracker.list.head;

                while (listTracker != null)
                {
                    Console.Write(listTracker.value + " ");
                    listTracker = listTracker.next;
                }

                tracker = tracker.next;
                Console.WriteLine(Environment.NewLine);
            }
        }