Skip to content
Snippets Groups Projects
Commit 44c6f631 authored by Florent Lamiraux's avatar Florent Lamiraux
Browse files

[c+=] Replace array by vector.

parent 4092f58e
No related branches found
No related tags found
No related merge requests found
......@@ -125,7 +125,7 @@ bool Gtsp::isTriangularInequalitySatisfied() {
Tour::Tour(const Gtsp &pb) : problem(pb) {
cost=0;
int prev=problem.getNode(0,0);
nodes = new int[problem.getNbClusters()];
nodes.resize(problem.getNbClusters());
nodes[0]=problem.getNode(0,0);
for (int i=1;i<problem.getNbClusters();i++) {
//std::cout << " arc " << prev << "->" << problem.getNode(i,0) << " cost=" << problem.getDist(prev,problem.getNode(i,0)) ;
......
......@@ -25,6 +25,7 @@
#define INCLUDED_GTSP_HPP
#include <list>
#include <vector>
// class Gtsp: stores the instance data
class Gtsp {
......@@ -54,10 +55,10 @@ class Tour {
const Gtsp &problem; // reference to the problem
double cost; // cost of the tour
int *nodes; // nodes[i] -> id of node at position i in the tour
std::vector<int> nodes; // nodes[i] -> id of node at position i in the tour
public:
Tour(const Gtsp &); // constructor from a problem -> create a Tour made of the first node of each cluster
~Tour() {delete [] nodes;}; // destructor
~Tour() {}; // destructor
double getCost(); // get the tour cost
void setCost(double); // set the tour cost
int getNodeAtPos(int); // get the id of the node at position i
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment