Ejemplo n.º 1
0
        private static Aufgabe2Results A(string path)
        {
            var graph = FileParser.Parse(path);

            Debug.WriteLine("EulerSolver for File: " + path);

            var result = new Aufgabe2Results();

            result.HasEulerCycle = EulerFinderAlgorithm.FindEulerCycle(graph);
            result.HasEulerPath  = EulerFinderAlgorithm.FindEulerPath(graph);
            result.HasCycle      = CycleFinderAlgorithm.FindCycle(graph);

            var startVertice = graph["I"];
            var endVertice   = graph["F"];

            result.shortestPath = DijkstraAlgorithm.FindShortestPath(graph, startVertice, endVertice);

            Debug.WriteLine("Eulerkreis: " + result.HasEulerCycle);
            Debug.WriteLine("Eulerpfad: " + result.HasEulerPath);
            Debug.WriteLine("Kreis: " + result.HasCycle);

            Debug.WriteLine("Shortest Dijkstra Path From " + startVertice.Name + " to " + endVertice.Name);

            result.shortestPath.Reverse();
            if (result.shortestPath.Count == 0)
            {
                Debug.WriteLine("Error!");
            }
            else
            {
                foreach (var v in result.shortestPath)
                {
                    Debug.Write(v.Name + " ");
                }
            }

            result.Graph = graph;

            return(result);
        }
Ejemplo n.º 2
0
        public static Grapher <VertexBase> B()
        {
            var graph = FileParser.Parse(@"TestFiles\Sudoku.txt"); // Knoten sind kästchenweise von links nach rechts und oben nach unten alphabetisch benannt
            var prefilledSudokuFields = new Dictionary <String, int>();

            prefilledSudokuFields.Add("E", 3);
            prefilledSudokuFields.Add("D", 1);
            prefilledSudokuFields.Add("I", 1);
            prefilledSudokuFields.Add("L", 3);
            prefilledSudokuFields.Add("P", 0);

            graph.Vertices.ForEach(v => v.Color = -1);

            SetPrefilledSudokuFields(graph, prefilledSudokuFields);

            var newgraph = graph.Clone();

            for (int i = 0; i < 1000; i++)
            {
                newgraph = GreedyColAlgorithm.ColorVerticesVarPrefilledRandom(graph);
            }

            return(newgraph);
        }