Advertisement
Guest User

Untitled

a guest
May 3rd, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. Grafo* Grafo::grupoInduzido(int noX[])
  2. {
  3. cout<<"\nGrupo Induzido: "<< endl;
  4. Grafo *subInduzido = new Grafo();
  5.  
  6. for (int i=0; noX[i] != NULL; i++)
  7. {
  8.  
  9. for(Vertice *v=vPri; v!=NULL; v=v->getNext())
  10. {
  11. if(v->getId() == noX[i])
  12. {
  13. for(Aresta *a=v->getApri(); a!=NULL; a=a->getNext())
  14. {
  15. for (int j=0; noX[j]!=NULL; j++)
  16. {
  17. if (a->getVertice2()->getId() == noX[j])
  18. {
  19. //cout<<"["<<a->getVertice1()->getId()<<"] - ";
  20. //cout<<"["<<a->getVertice2()->getId()<<"] " << endl;
  21.  
  22. Vertice* v1 = new Vertice(v->getId());
  23. Vertice* v2 = new Vertice(a->getVertice2()->getId());
  24.  
  25. Aresta*a = new Aresta(v1, v2);
  26.  
  27. v1->addAresta(a);
  28. subInduzido->addVertice(v1);
  29. }
  30. }
  31. }
  32. }
  33. }
  34.  
  35. }
  36. return subInduzido;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement