Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Grafo* Grafo::grupoInduzido(int noX[])
- {
- cout<<"\nGrupo Induzido: "<< endl;
- Grafo *subInduzido = new Grafo();
- for (int i=0; noX[i] != NULL; i++)
- {
- for(Vertice *v=vPri; v!=NULL; v=v->getNext())
- {
- if(v->getId() == noX[i])
- {
- for(Aresta *a=v->getApri(); a!=NULL; a=a->getNext())
- {
- for (int j=0; noX[j]!=NULL; j++)
- {
- if (a->getVertice2()->getId() == noX[j])
- {
- //cout<<"["<<a->getVertice1()->getId()<<"] - ";
- //cout<<"["<<a->getVertice2()->getId()<<"] " << endl;
- Vertice* v1 = new Vertice(v->getId());
- Vertice* v2 = new Vertice(a->getVertice2()->getId());
- Aresta*a = new Aresta(v1, v2);
- v1->addAresta(a);
- subInduzido->addVertice(v1);
- }
- }
- }
- }
- }
- }
- return subInduzido;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement