Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef MATRICE_H_INCLUDED
- #define MATRICE_H_INCLUDED
- #include <iostream>
- #include <fstream>
- #include <math.h>
- #include <vector>
- #include <limits>
- using namespace std;
- class matrice
- {
- private:
- vector <float> matrix;
- fstream prelevato;
- float app;
- int dimensione;
- int Npath, bestDist, actualDist;
- vector <float> X;
- vector <float> Y;
- vector <bool> visitate;
- vector <int> actualPath;
- vector <int> bestPath;
- double DistanzaGreedy, DistanzaBack;
- public:
- matrice(string prelevato_i)
- {
- prelevato.open(prelevato_i, ios::in);
- prelevato>>dimensione;
- dimensione=dimensione+1;
- X.push_back(0);
- Y.push_back(0);
- while(!prelevato.eof())
- {
- prelevato>>app;
- X.push_back(app);
- prelevato>>app;
- Y.push_back(app);
- }
- prelevato.close();
- for(int i=0; i<dimensione;i++)
- {
- for(int j=0; j< dimensione; j++)
- {
- app=sqrt(pow(X[i]-X[j],2)+pow(Y[i]-Y[j],2));
- matrix.push_back(app);
- }
- }
- for(int i=0; i<dimensione; i++)
- {
- visitate.push_back(false);
- }
- visitate.at(0)=true;
- actualDist=0;
- Npath=0;
- bestDist=INT_MAX;
- actualPath.push_back(0);
- bestPath.push_back(0);
- }
- ~matrice(){;};
- void stampa_matrice()
- {
- for (int i=0; i<dimensione; i++)
- {
- for(int j=0; j< dimensione; j++)
- {
- cout<<matrix.at(i*dimensione+j)<<"\t\t";
- }
- cout<<endl;
- }
- }
- /*void EseguiPasso(int Npath, int actualDist)
- {
- for(int j=0; j< dimensione; j++)
- {
- if(visitate.at(j)==false)
- {
- if(actualDist + matrix.at(Npath*dimensione+j)+ matrix.at(j*dimensione+1) < bestDist)
- {
- bool esplorabile= false;
- for (int k=0; k< dimensione; k++)
- esplorabile=visitate.at(k)|esplorabile;
- if(esplorabile)
- {
- actualPath.push_back(j);
- visitate.at(j)=true;
- EseguiPasso(Npath+1,actualDist+matrix.at(Npath*dimensione+j));
- visitate.at(j)=false;
- }
- }
- }
- }
- }*/
- };
- #endif // MATRICE_H_INCLUDED
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement