Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- #include <iostream>
- #include <fstream>
- #include "array_queue.hpp"
- #include "hash_graph.hpp"
- #include "dijkstra.hpp"
- std::string get_node_in_graph(const ics::DistGraph& g, std::string prompt, bool allow_QUIT) {
- std::string node;
- for(;;) {
- node = ics::prompt_string(prompt + " (must be in graph" + (allow_QUIT ? " or QUIT" : "") + ")");
- if ( (allow_QUIT && node == "QUIT") || g.has_node(node) )
- break;
- }
- return node;
- }
- int main() {
- try {
- std::ifstream input_file;
- std::string fileName= ics::prompt_string("Enter graph file name");
- input_file.open(fileName);
- ics::DistGraph Graph;
- Graph.load(input_file, ";");
- std::cout << Graph;
- std::string startNode = get_node_in_graph(Graph, "Enter valid starting Node: ", false);
- ics::CostMap answer_map = ics::extended_dijkstra(Graph, startNode);
- std::string endNode = "";
- while(endNode != "QUIT"){
- endNode = get_node_in_graph(Graph, "Enter valid end Node:", true);
- if(endNode != "QUIT") {
- std::cout << ics::recover_path(answer_map, endNode);
- }
- }
- } catch (ics::IcsError& e) {
- std::cout << e.what() << std::endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement