Guest User

Untitled

a guest
Jun 24th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.90 KB | None | 0 0
  1. void Fabrica::postos_alcancaveis(const PostoTrabalho &posto_ini)
  2. {
  3.         Vertice<PostoTrabalho, int> *apinicio = ListAdjGrafo<PostoTrabalho,int>::encvert_conteudo(posto_ini);
  4.         if(apinicio!=NULL)
  5.                 postos_alcancaveis(apinicio);
  6. }
  7. void Fabrica::postos_alcancaveis( Vertice<PostoTrabalho,int> * apinicio)
  8. {
  9.         int fornecimento_total=apinicio->GetConteudo().getTempo();
  10.         int percurso_total=0;
  11.         int *v=new int[NumVert()+1];
  12.         for (int i =1; i<NumVert()+1; ++i)
  13.                 v[i]=0;
  14.         Queue<Vertice<PostoTrabalho,int> *> q;
  15.         Ramo<PostoTrabalho,int> * apramo;
  16.         cout << apinicio->GetConteudo();
  17.         v[apinicio->GetKey()]=1;
  18.         q.insere(apinicio);
  19.         while(!q.vazia())
  20.         {
  21.                 q.retira(apinicio);
  22.                 apramo=apinicio->GetRamo();
  23.                 while(apramo!=NULL)
  24.                 {
  25.                         if (v[apramo->GetVertice()->GetKey()]==0)
  26.                         {
  27.                                 percurso_total += apramo->GetConteudo();
  28.                                 fornecimento_total += apramo->GetVertice()->GetConteudo().getTempo();
  29.                                 cout << apramo->GetConteudo()<<","<<apramo->GetVertice()->GetConteudo();
  30.                                 v[apramo->GetVertice()->GetKey()]=1;
  31.                                 q.insere(apramo->GetVertice());
  32.                         }
  33.                         apramo=apramo->GetRamo();
  34.                 }
  35.         }
  36.         cout << "Tempo total de fornecimento: " << fornecimento_total<<endl;
  37.         cout << "Tempo total de percurso: " << percurso_total<<endl;
  38. }
  39. void Fabrica::postos_alcancaveisRec(const PostoTrabalho & p)
  40. {
  41.         vector<bool> visitados(NumVert()+1,false);
  42.         Vertice<PostoTrabalho,int> * apv=encvert_conteudo(p);
  43.         if(apv!=NULL)
  44.                 postos_alcancaveisRec(apv,visitados);
  45. }
Add Comment
Please, Sign In to add comment