Compare commits

...

3 Commits

Author SHA1 Message Date
47479936e0 Fixed cost 2023-09-10 22:11:18 -05:00
7c73089916 Added cost 2023-09-10 22:10:14 -05:00
69634746c6 Added time findings 2023-09-10 22:03:06 -05:00
2 changed files with 24 additions and 1 deletions

View File

@ -54,9 +54,20 @@ void Graph::PrintGraph(void) {
} }
void PrintSolution(std::vector<Vertex*> solution) { void PrintSolution(std::vector<Vertex*> solution) {
int cost = 0;
std::cout << "Path: "; std::cout << "Path: ";
for (Vertex* i : solution) { std::cout << i->nodeNumber << ' '; } Vertex* lastVertex = solution.front();
for (Vertex* i : solution) {
std::cout << i->nodeNumber << ' ';
for (Edge j : lastVertex->edges) {
if (j.destination->nodeNumber == i->nodeNumber) {
cost += j.weight;
}
}
lastVertex = i;
}
std::cout << std::endl; std::cout << std::endl;
std::cout << "Cost: " << cost << std::endl;
} }
void UCBFS(Graph graph, int start) { void UCBFS(Graph graph, int start) {

12
times.txt Normal file
View File

@ -0,0 +1,12 @@
BFS:
- 10: 0.052015
- 20: 0.05767
- 100: 0.123823
DFS:
- 10: 0.02199
- 20: 0.034288
- 100: 0.092118
UCBFS:
- 10: 0.141568
- 20: 0.288738
- 100: 1.31126