Advertisement
Guest User

Untitled

a guest
May 24th, 2015
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. /*---------------------------Aproximado-----------------------------------------*/
  2. Grafo *encontra_caminho2(Grafo *g)
  3. {
  4. //Gerando a Arvore.
  5. Grafo *h = geraArvore(g);
  6. if(h == NULL)
  7. {
  8. printf("Ocorreu um erro ao gerar a arvore.");
  9. deletaGrafo(g);
  10. return NULL;
  11. }
  12.  
  13. int ultimovisitado = 0; // Ultimo vertice visitado pela busca em profundidade.
  14. int teste = 0; //Sequencia em que o ultimo vertice foi visitado.
  15.  
  16. int i,visitados[h->nro_vertices];
  17.  
  18. buscaProfundidade_Grafo(h,0,visitados);
  19.  
  20. for(i=0;i<h->nro_vertices;i++)
  21. {
  22. if(visitados[i] > teste)
  23. {
  24. ultimovisitado = i;
  25. teste = visitados[i];
  26. }
  27. }
  28. Insere_aresta(h,0,ultimovisitado,getPeso(g,0,ultimovisitado),1);
  29. printf("\nUltimovisitado %d",ultimovisitado);
  30. return h;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement