-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.cpp
83 lines (59 loc) · 1.78 KB
/
main.cpp
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <iostream>
#include <cstdlib>
#include <string>
#include "include/graph.h"
#include "include/diff_graph.h"
#include "include/dynamic_graph.h"
#include "include/a_star.h"
#ifdef __NVCC__
#include <cuda.h>
#include "include/graph.cuh"
#include "include/a_star.cuh"
#endif
int main(){
Graph<unsigned int > graph;
std::string filename = "graph.txt";
graph.read_graph(filename);
Dynamic_Graph<unsigned int> dgraph(&graph);
int* edge = dgraph.get_graph().get_edges();
int* off = dgraph.get_graph().get_offsets();
unsigned int* w = dgraph.get_graph().get_weights();
for(int i=0;i<graph.get_num_edges();i++){
std::cout<<edge[i]<<" ";
}
std::cout<<"\n";
for(int i=0;i<graph.get_num_nodes();i++){
std::cout<<off[i]<<" ";
}
std::cout<<"\n";
for(int i=0;i<graph.get_num_edges();i++){
std::cout<<w[i]<<" ";
}
std::cout<<"\n";
int start= 0;
int end = 7;
int* hx = (int*)malloc(sizeof(int)*graph.get_num_nodes());
for(int i=0;i<graph.get_num_nodes();i++)
hx[i] = 0;
A_Star <unsigned int,int>* algo = new A_Star<unsigned int,int>(&dgraph,start,end,1);
algo->set_heuristics(hx);
std::vector<int> path = algo->get_path();
for(int i=0;i<path.size();i++){
printf("%d ",path[i]);
}
printf("\n");
path.clear();
#ifdef __NVCC__
GPU_Graph<unsigned int> g(&graph);
printf("allocated\n");
GPU_Dynamic_Graph<unsigned int> dg(&g);
GPU_A_Star < unsigned int, int > g_algo(&dg,start,end,1);
g_algo.set_heuristics(hx);
path = g_algo.get_path();
for(int i=0;i<path.size();i++){
printf("%d ",path[i]);
}
printf("\n");
#endif
return 0;
}