示例#1
0
        static Graph convert(string filePath)
        {
            Graph result = new Graph();

            try
            {
                result = Converter.convert(filePath);
                SVGcreator.drawGraph("graph.svg", filePath, result);
                Console.WriteLine("Your map has been converted. The resulting graph is in graph.svg");
            }
            catch
            {
                Console.WriteLine("Error converting the map into a graph");
                string response = "";
                do
                {
                    Console.WriteLine("Try again? Y/N");
                    response = Console.In.ReadLine();
                    if (response == "Y" || response == "y")
                    {
                        filePath = askPath();
                        result   = convert(filePath);
                    }
                }while (response != "Y" && response != "N" && response != "y" && response != "n");
            }

            return(result);
        }
示例#2
0
        static void search(int end_office, Graph my_graph, string filePath)
        {
            int start_office = 7104;

            try
            {
                Node start_node = my_graph.findNodeByOfficeNumber(start_office);
                Node end_node   = my_graph.findNodeByOfficeNumber(end_office);
                MinCostPathFinder pathfinder = new MinCostPathFinder();
                Path shortest_path           = pathfinder.findPath(start_node, end_node);
                SVGcreator.drawPath("path.svg", filePath, shortest_path);
                Console.WriteLine("Your path has been calculated. The resulting path is in path.svg");
            }
            catch (Exception e)
            {
                Console.WriteLine("The path cannot be calculated");
            }

            getNewCommands(my_graph, filePath);
        }