-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShortestPaths.cpp
More file actions
36 lines (28 loc) · 779 Bytes
/
Copy pathShortestPaths.cpp
File metadata and controls
36 lines (28 loc) · 779 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "ShortestPaths.hpp"
int main()
{
using std::cout;
using std::endl;
Graph G(5);
G.add_edge(0, 1, 5);
G.add_edge(0, 2, 9);
G.add_edge(1, 2, 3);
G.add_edge(2, 3, 4);
G.add_edge(3, 4, 5);
Vertex s = 0;
Vertex t = 4;
std::vector<int> heuristic = {5, 5, 4, 4, 0};
cout << "Dijsktra produces the following path:\n\t";
for (auto e : Dijkstra(G, s, t))
{
cout << "----(w = " << e.weight() << ")----> " << e.vertex << " ";
}
cout << endl << endl;
auto h = [&heuristic](Vertex v) { return heuristic[v]; };
cout << "A* produces the following path:\n\t";
for (auto e : Astar(G, s, t, h))
{
cout << "----(w = " << e.weight() << ")----> " << e.vertex << " ";
}
return 0;
}