Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Fabrica::postos_alcancaveis(const PostoTrabalho &posto_ini)
- {
- Vertice<PostoTrabalho, int> *apinicio = ListAdjGrafo<PostoTrabalho,int>::encvert_conteudo(posto_ini);
- if(apinicio!=NULL)
- postos_alcancaveis(apinicio);
- }
- void Fabrica::postos_alcancaveis( Vertice<PostoTrabalho,int> * apinicio)
- {
- int fornecimento_total=apinicio->GetConteudo().getTempo();
- int percurso_total=0;
- int *v=new int[NumVert()+1];
- for (int i =1; i<NumVert()+1; ++i)
- v[i]=0;
- Queue<Vertice<PostoTrabalho,int> *> q;
- Ramo<PostoTrabalho,int> * apramo;
- cout << apinicio->GetConteudo();
- v[apinicio->GetKey()]=1;
- q.insere(apinicio);
- while(!q.vazia())
- {
- q.retira(apinicio);
- apramo=apinicio->GetRamo();
- while(apramo!=NULL)
- {
- if (v[apramo->GetVertice()->GetKey()]==0)
- {
- percurso_total += apramo->GetConteudo();
- fornecimento_total += apramo->GetVertice()->GetConteudo().getTempo();
- cout << apramo->GetConteudo()<<","<<apramo->GetVertice()->GetConteudo();
- v[apramo->GetVertice()->GetKey()]=1;
- q.insere(apramo->GetVertice());
- }
- apramo=apramo->GetRamo();
- }
- }
- cout << "Tempo total de fornecimento: " << fornecimento_total<<endl;
- cout << "Tempo total de percurso: " << percurso_total<<endl;
- }
- void Fabrica::postos_alcancaveisRec(const PostoTrabalho & p)
- {
- vector<bool> visitados(NumVert()+1,false);
- Vertice<PostoTrabalho,int> * apv=encvert_conteudo(p);
- if(apv!=NULL)
- postos_alcancaveisRec(apv,visitados);
- }
Add Comment
Please, Sign In to add comment