Added cost

This commit is contained in:
TriantaTV 2023-09-10 22:10:14 -05:00
parent 69634746c6
commit 7c73089916

View File

@ -54,9 +54,19 @@ 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;
}
}
}
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) {