Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  cpp
Language: C/C++
Code:
#include "Dijkstra.hpp"
#include <fstream>

ifstream inFile;
int main()
{
    int n;
    inFile.open("data.txt");
    inFile >> n;
    graph.resize(n+1);
    vis.resize(n+1);
    parent.resize(n+1);
    while(!inFile.eof())
    {
        int u, v, c;
        inFile >> u >> v >> c;
        addEdge(u,v,c);
    }
    int u, v;
    while(true)
    {
        cout << "Your location is: " << endl;
        cin >> u;
        cout << "Your destination is:" << endl;
        cin >> v;
        if(!u && !v) break;
        vis.clear();
        parent.clear();
        vis.resize(n+1);
        parent.resize(n+1);
        cout << "The best route from " << u << " to " << v << " is:" << endl;
        cout << dijkstra(u, v) << endl;
    }

}
Comments: