Beispiel #1
0
        static void Main(string[] args)
        {
            //Implementeer een graaf-klasse met nodes en edges waarbij je gebruikt maakt van de code uit het boek.
            //Schrijf ook een methode die de graaf als tekst op het scherm zet (een lijst van nodes en bijbehorende edges).

            var exerciseGraph = new Graph();

            exerciseGraph.AddEdge("V2", "V0", 4);
            exerciseGraph.AddEdge("V2", "V5", 5);

            exerciseGraph.AddEdge("V0", "V1", 2);
            exerciseGraph.AddEdge("V0", "V3", 1);

            exerciseGraph.AddEdge("V1", "V3", 3);
            exerciseGraph.AddEdge("V1", "V4", 10);

            exerciseGraph.AddEdge("V3", "V2", 2);
            exerciseGraph.AddEdge("V3", "V5", 8);
            exerciseGraph.AddEdge("V3", "V6", 4);
            exerciseGraph.AddEdge("V3", "V4", 2);

            exerciseGraph.AddEdge("V6", "V5", 1);

            exerciseGraph.AddEdge("V4", "V6", 6);

            exerciseGraph.Calculate("V2");

            //exerciseGraph.PrintPath("V4");
            //exerciseGraph.PrintPath("V2");
            exerciseGraph.PrintPath("V6");

            Console.WriteLine(exerciseGraph.IsConnected());

            exerciseGraph.AddEdge("V7", "V8", 6);

            Console.WriteLine(exerciseGraph.IsConnected());

            //exerciseGraph.Print();

            var cityGraph = new Graph();

            cityGraph.AddEdge("grafhorst", "kampen", 3);
            cityGraph.AddEdge("grafhorst", "ijsselmuiden", 1);
            cityGraph.AddEdge("grafhorst", "genemuiden", 8);

            cityGraph.AddEdge("ijsselmuiden", "kampen", 1);
            cityGraph.AddEdge("ijsselmuiden", "genemuiden", 10);

            cityGraph.AddEdge("kampen", "genemuiden", 4);

            cityGraph.AddEdge("genemuiden", "ijsselmuiden", 6);

            //cityGraph.Print();

            Console.ReadKey();
        }