Пример #1
0
void prim(Graph & G, int bench)
{
    if(!bench)
    {
        int v;
        float length = 0;
        std::cout << "Vértice de origen: ";
        while(!(std::cin >> v)){
            std::cin.clear();
            std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
            std::cout << "Entrada inválida, intenta otra vez: ";
        }
        if(vertexExists(G, v))
        {
            std::vector<int> parents = primPrincipal(G,length,v);
            int node = 1;
            for (int i = 0 ; i< parents.size(); i++)
            {
                if(parents[node-1] == -1)
                    std::cout << "null -> " << node << std::endl;
                else
                    std::cout << parents[node-1] << " -> " << node << std::endl;
                node++;
            }
            std::cout << "Length: " << length << std::endl;
        }
        else
        {
            std::cout << "El vértice " << v << " no existe" << std::endl;
        }
    }
Пример #2
0
 VertexId PoseGraph::nextVertexId() 
 {
     while (vertexExists(_nextVertexId))
         _nextVertexId++;
     return _nextVertexId;
 }