-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
44 lines (35 loc) · 1023 Bytes
/
main.cpp
File metadata and controls
44 lines (35 loc) · 1023 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
37
38
39
40
41
42
43
44
/*
* main.cpp
*
* Created on: Sep 17, 2021
* Author: d-w-h
*/
#include <iostream>
#include <vector>
#include "dijkstra.hpp"
int main(int argc, char* argv[]) {
//Declarations
int s = 2; //Start vertex. The minimum index for vertices is 1
int n = 2499; //Number of vertices
int numEdges = 33125; //Number of edges
//Create edges
std::vector< std::vector<int> > edges;
for(int i = 0; i < numEdges; ++i) {
int startVertex = rand() % n + 1;
int endVertex = rand() % n + 1;
int weight = rand() % 200 + 1;
std::vector<int> edge;
edge.push_back(startVertex);
edge.push_back(endVertex);
edge.push_back(weight);
edges.push_back(edge);
}
//Compute distances to Nodes from start vertex
std::vector<int> results = dijkstra(n, edges, s);
//Print results
int size_results = (int) results.size();
for(int i = 0; i < size_results; ++i) {
std::cout << results[i] << " ";
}
return 0;
}