コード例 #1
0
ファイル: Program.cs プロジェクト: marcellalves/graphs
        static void Main(string[] args)
        {
            //Lets create nodes as given as an example in the article
            var nA = new AdjacencyMatrixGraph.Node('A');
            var nB = new AdjacencyMatrixGraph.Node('B');
            var nC = new AdjacencyMatrixGraph.Node('C');
            var nD = new AdjacencyMatrixGraph.Node('D');
            var nE = new AdjacencyMatrixGraph.Node('E');
            var nF = new AdjacencyMatrixGraph.Node('F');

            //Create the graph, add nodes, create edges between nodes
            var g = new AdjacencyMatrixGraph();
            g.AddNode(nA);
            g.AddNode(nB);
            g.AddNode(nC);
            g.AddNode(nD);
            g.AddNode(nE);
            g.AddNode(nF);
            g.SetRootNode(nA);

            g.ConnectNode(nA, nB);
            g.ConnectNode(nA, nC);
            g.ConnectNode(nA, nD);

            g.ConnectNode(nB, nE);
            g.ConnectNode(nB, nF);
            g.ConnectNode(nC, nF);

            g.BreadthFirstSearch();
            Console.ReadLine();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: Sansiel/Algorithms_CSharp
        static void Main(string[] args)
        {
            string choose = "";

            while (choose != "stop")
            {
                Console.WriteLine("Choose - DoubleLinkedList (d) / CircleLinkedList (c) / MatrixGraph (m) / ListGraph(l) / BinaryTree (b) / HashTable (h)");
                choose = Console.ReadLine();
                switch (choose)
                {
                case "d":
                    DoubleLinkedList.MainG();
                    break;

                case "c":
                    CircleList.MainG();
                    break;

                case "m":
                    AdjacencyMatrixGraph.MainG();
                    break;

                case "l":
                    AdjacencyListGraph.MainG();
                    break;

                case "b":
                    BinaryTree.MainG();
                    break;

                case "h":
                    HashTableExample.MainG();
                    break;
                }
                Console.WriteLine("To end program type 'stop'");
            }
        }