Added cost
This commit is contained in:
parent
69634746c6
commit
7c73089916
@ -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) {
|
||||||
|
Loading…
Reference in New Issue
Block a user