Advertisement
Guest User

Untitled

a guest
Dec 13th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. void primOmegaMejor(Grafo g)
  2. {
  3. int n = g.size();
  4. vector<int> vecino;
  5. vecino.push_back(0);
  6. vector<float> pVecino;
  7.  
  8. int c = 0, filaMin;
  9. float min, act;
  10. while(((int)vecino.size()) !=n)
  11. {
  12. min = FLT_MAX;
  13. for(int f = 1; f < n; f++)
  14. {
  15. if (find(vecino.begin(), vecino.end(), f) == vecino.end())
  16. {
  17. act = g(c,f);
  18. if(act < min)
  19. {
  20. min = act;
  21. filaMin = f;
  22. }
  23. }
  24. }
  25. vecino.push_back(filaMin);
  26. pVecino.push_back(min);
  27. c = filaMin;
  28. }
  29. for(int i = 0; i < n;i++)
  30. {
  31. cout << vecino.at(i) << " > ";
  32. }
  33. cout << endl;
  34. for(int i = 0; i < n-1;i++)
  35. {
  36. cout << pVecino.at(i) << " > ";
  37. }
  38. cout << endl << endl;
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement