void Grafo::JsonArvoreMinima() { std::vector<Aresta *> lArestas = this->Kruskal(); int custo = 0; int id1, id2; cout << "{\"arvoreminima\":{\"arestas\":["; for(int i = 0; i < (int) lArestas.size(); i++) { Aresta * cAresta = lArestas[i]; if (i > 0) cout << ","; id1 = cAresta->GetId1(); id2 = cAresta->GetId2(); custo+= cAresta->GetPeso(); cout << "(" << id1 << "," << id2 << ")"; } cout << "],\"custo\":" << custo << "}}" << endl; }
Aresta::Aresta(const Aresta & cAresta) { this->id1 = cAresta.GetId1(); this->id2 = cAresta.GetId2(); this->peso = cAresta.GetPeso(); }