Exemplo n.º 1
0
void Application::run()
{
	ra->init();

	EventManager::getInstance()->subscribe(this);

	MapFileReader reader("res/map.txt");
	graph = reader.getGraph();

	graph->updateNeighborhood();

	GraphDrawer drawer(graph, ra);

	Cell::Coord p1, p2;
	p1.x = 0;
	p1.y = 0;
	p2.x = graph->getWidth()-1;
	p2.y = graph->getHeight()-1;
	Dijkstra *astar = new Dijkstra(graph, p1, p2);

	drawer.createEdges();
	drawer.createNodes();

	astar->start();

	while (running)
	{
		EventManager::getInstance()->captureEvent();

		Application::lockRessources();
		ra->display();
		Application::unlockRessources();
	}
}
Exemplo n.º 2
0
void MainWindow::on_BTNdijkstra_clicked()
{
    layout->removeWidget(label);
    dijkstra.resolver(ui->DBsrc->currentIndex());
    dijkstra.print();
    layout->addWidget(label);
}
Exemplo n.º 3
0
	virtual void SetUp() {
		RotasTest::SetUp();

		using namespace teitz_bart;
		Dijkstra dijkstra = Dijkstra();
		TeitzBart teitz_bart = TeitzBart();

		cout << "Total de cidades: " << cidades.size() << endl;


		for (size_t i = 0; i < cidades.size(); i++)
		{
			Cidade c = cidades.at(i);

			c.set_rotas(dijkstra.dijkstra_menor_caminho(rotas_context, c));

			cidades_dijkstra.push_back(c);
		}

		teitz_bart.define_medianas(cidades_dijkstra, qtd_sedes);

		cout << "Cidades sedes: " << endl;

		unsigned int qtd_medianas = 0;

		for (size_t i = 0; i < cidades_dijkstra.size(); i++)
		{
			Cidade& c = cidades_dijkstra[i];

			if (c.is_mediana())
			{
				cout << "\t* " << c.get_nome() << endl;
				qtd_medianas++;
			}
		}

		gillet_johnson = algoritmos::GilletJohnson();
		
		a = 5;

		

		for (unsigned int i = 0; i < cidades_dijkstra.size(); i++) {
			if (cidades_dijkstra[i].is_mediana()) {
				pontos_atendimento.push_back(&(cidades_dijkstra[i]));
			}
		}

		

		// Capacidades dos 3 caminhões
		double capacidades[] = { 6200, 8300, 11000 };

		for (size_t i = 0; i < pontos_atendimento.size(); i++) {
			pontos_atendimento[i]->set_capacidade(capacidades[i % 3]);
		}

		gillet_johnson.encontra_medianas(cidades_dijkstra);

	}
Exemplo n.º 4
0
int main()
{
  Dijkstra algorithm;
  if (!algorithm.Init(3, 67, 100, 100)) 
  { 
    std::cout << "...Initialization failed." << std::endl; 
    return 0; 
  }
  return 0;
}
Exemplo n.º 5
0
int main()
{
	Dijkstra ds;
	
	ds.ReadGraph("input.txt");
	
	std::cout << "Shortest path between 0 and 6 : ";
	
	ds.FindPath(0,6);
	
	return 0;
}
Exemplo n.º 6
0
/**
 * Initialize the random initialisation
 * @param anz [description]
 */
void ShortPath::init_random(int anz){
    num_of_vertices = anz;
    elements.clear();
    for (int i = 0; i < num_of_vertices; i++){
        Dijkstra d;
        d.set_name(concat_string_and_int("J&P",i));
        d.set_mark(false);
        d.set_predecessor(-1);
        d.set_position(i);
        elements.push_back(d);
    }
    init_random_distances();
}
/**
 * Encontra dois caminhos disjuntos usando Dijkstra
 * A partir deles calcula o limit para o número de hops 
 */
int WorstBalancedPathEdge::limitNumberOfNodesInPath(Graph g, int source,int target)
{
    Graph s = g;//grafo auxiliar

    Dijkstra d;

    d.execute(s,source,target);

    vector<int> p1;

    p1 = d.shortestPath(target);

    if ((int)p1.size() <= 1)
    {
        return 0;
    }

    /**
     * Remove arestas do grafo
     */
    int sum = (int)p1.size();
    vector<int> adjcents;
    Node node;


    int u = 0;

    for ( u = 0; u < (int)p1.size()-1; u++)
    {
        s.removeNode(p1[u],p1[u+1]);
        s.removeNode(p1[u+1],p1[u]);
    }

    p1.clear();

    d.execute(s,source,target);

    p1 = d.shortestPath(target);

    if ((int)p1.size() <= 1 )
    {
        return 0;
    }

    sum = sum + (int) p1.size();

    p1.clear();

    return sum;
}
Exemplo n.º 8
0
void main(int argc, char* argv[])
{
	Dijkstra* sPath = new Dijkstra();

	Vertex* head = new Vertex(0,"v1");

	//BUG: the comparison on the Vertex* will fail during insert/remove
	BinaryHeap<Vertex*>* pQ = new BinaryHeap<Vertex*>();
	pQ->Insert(head);

	Vertex* current = pQ->RemoveMin();
	sPath->ShortestPath(current, pQ);

	getchar();
}
int main(){
	char c;
	clock_t start, end;

	Dijkstra G;
	int** matrix = G.read();
	start = clock();
	G.calculateDistance(matrix);
	end = clock();
	G.output();

	cout << "\nExecution Time: " << (double)(end - start)/CLOCKS_PER_SEC << " seconds" << endl;
	cout << "Enter a character to exit: ";
	cin >> c;
	return 0;
}
Exemplo n.º 10
0
int main() {
  int kase = 0, N, S, E, M, K, X, Y, Z;
  while(scanf("%d%d%d%d", &N, &S, &E, &M) == 4) {
    solver.init(N);

    S--; E--; // 编号从0~N-1
    for(int i = 0; i < M; i++) {
      scanf("%d%d%d", &X, &Y, &Z); X--; Y--;
      solver.AddEdge(X, Y, Z);
      solver.AddEdge(Y, X, Z);
    }
    solver.GetShortestPaths(S, d1, paths1); // S到所有点的距离和路径
    solver.GetShortestPaths(E, d2, paths2); // T到所有点的距离和路径

    int ans = d1[E];              // 初始解解为直达距离
    vector<int> path = paths1[E]; // 初始解的station序列
    int midpoint = -1;            // 不坐商业线

    scanf("%d", &K);
    for(int i = 0; i < K; i++) {
      scanf("%d%d%d", &X, &Y, &Z); X--; Y--;
      for(int j = 0; j < 2; j++) { // j=0代表商业线坐X->Y,j=1代表Y->X
        if(d1[X] + d2[Y] + Z < ans) {
          ans = d1[X] + d2[Y] + Z;
          path = paths1[X];
          for(int j = paths2[Y].size()-1; j >= 0; j--) // 从Y到T的距离要反过来
            path.push_back(paths2[Y][j]);
          midpoint = X;
        }
        swap(X, Y);
      }
    }

    if(kase != 0) printf("\n");
    kase++;

    for(int i = 0; i < path.size()-1; i++) printf("%d ", path[i]+1);
    printf("%d\n", E+1);
    if(midpoint == -1) printf("Ticket Not Used\n"); else printf("%d\n", midpoint+1);
    printf("%d\n", ans);
  }
  return 0;
}
Exemplo n.º 11
0
int main() 
{
  int n, m;
  while(scanf("%d%d", &n, &m) == 2) 
  {
    solver.init(n);
    for(int i = 0; i < m; ++i) 
	{
      int a, b, c;
      scanf("%d%d%d", &a, &b, &c); --a; --b;
      solver.AddEdge(a, b, c);
      solver.AddEdge(b, a, c);
    }

    solver.dijkstra(1); // 家(1)到所有点的距离。因为道路都是双向的,所以把家看作起点也行
    memset(d, -1, sizeof(d));
    printf("%d\n", dp(0)); // 办公室(0)到家的符合条件的路径条数
  }
  return 0;
}
Exemplo n.º 12
0
int main()
{
    int t;
    scanf("%d",&t);
    for(int i = 1;i <= t;i ++)
    {
        memset(edges,0,sizeof(edges));
        memset(next,0,sizeof(next));
        memset(head,0,sizeof(head));
        maps.clear();
        int tott = 0;
        tot = 0;
        scanf("%d",&n);
        dijkstra.init(n);
        for(int i = 1;i <= n;i ++)
        {
            string s1;
            int ct;
            cin>>s1;
            maps[s1] = ++tott;
            scanf("%d",&ct);
            for(int i = 1;i <= ct;i ++)
            {
                int a,b;
                scanf("%d%d",&a,&b);
                build(maps[s1],a,b);
            }
        }
        int q;
        scanf("%d",&q);
        string s1,s2;
        for(int i = 1;i <= q;i ++)
        {
            cin>>s1>>s2;
            dijkstra.dijkstra(maps[s1]);
            printf("%d\n",dijkstra.d[maps[s2]]);
        }
    }
    return 0;
}
int main()
{
#ifdef _Rayn
    //freopen("in.txt", "r", stdin);
#endif // _Rayn
    int T, P, Q;
    int u, v;
    LL w;

    scanf("%d", &T);
    while(T--)
    {
        scanf("%d%d", &P, &Q);
        Come.Init(P, Q);
        Back.Init(P, Q);
        for(int i = 0; i < Q; ++i)
        {
            scanf("%d%d%lld", &u, &v, &w);
            Come.AddEdge(u, v, w);
            Back.AddEdge(v, u, w);
        }
        Come.Solve(1);
        Back.Solve(1);
        long long ans = 0;
        for(int i = 1; i <= P; ++i)
        {
            ans += Come.dis[i] + Back.dis[i];
        }
        printf("%lld\n", ans);
    }
    return 0;
}
Exemplo n.º 14
0
int main(int argc, char const *argv[])
{
	READ;
	WRITE;
	read();
	Dijkstra dijkstra;
	dijkstra.init();
	for(int i = 0 ; i < 300 ; i ++)
	{
		for(int j = 0 ; j < 300 ; j++)
		{
			if(g[i][j]!=-1)
			{
				// printf("* %c %c %d\n",i,j,g[i][j]);
				dijkstra.AddEdge(i, j, g[i][j]);
			}
		}
	}

	dijkstra.dijkstra('Z');
	return 0;
}
int main()
{
	//Get data
	Search dfs;
	dfs.populateMatrix("distanceMatrix.txt");
	

	dfs.displayKey();

	Dijkstra d;
	d.populateMatrix("distanceMatrix.txt");
	
	// Get input
	cout << "Enter the start intersection number: ";
	int begin;
	cin >> begin;
	
	cout << "Enter the end intersection number: ";
	int end;
	cin >> end;

	//Perform DFS algorithm
	dfs.DFS(begin, end);
	cout << "-------------------------" << endl;
	cout << "DFS" << endl;
	dfs.displayList();

	//Perform Dijkstra's algorithm
	d.dijkstra(begin, end);
	cout << "-------------------------" << endl;
	cout << "DIJKSTRA" << endl;
	d.displayList();

	cout << "Press Enter to Exit" << endl;
	cin.ignore(10, '\n');	
	cin.get();
	return 0;
}
Exemplo n.º 16
0
int _tmain(int argc, _TCHAR* argv[])
{
	string file = "adjacencyMatrix.txt";
	Graph G;
	G.LoadGraph(file,1);

	cout<<"*********************************************************\n";
	cout<<"\t\tVisit Graph\n";
	cout<<"*********************************************************\n";
	G.BreadthFirstSearch();
	G.DepthFirstSearch();

	string file2 = "weightedAdjacencyMatrix.txt";
	G.LoadGraph(file2,2);

	cout<<"*********************************************************\n";
	cout<<"\t\tMinimum spanning tree\n";
	cout<<"*********************************************************\n";
	Kruskal k;
	k.MSTKruskal(G.vertexNumber,G.weightedAdjacencyMatrix);

	Prim p;
	int startVertex = 0;
	p.MSTPrim(G.vertexNumber,G.weightedAdjacencyMatrix,startVertex);

	string file3 = "weightedDirectedGraph.txt";
	G.LoadGraph(file3,3);

	cout<<"*********************************************************\n";
	cout<<"\t\tSingle-source shortest path \n";
	cout<<"*********************************************************\n";
	Dijkstra d;
	d.SSSPDijkstra(G.vertexNumber,G.weightedDirectedAdjacencyMatrix,startVertex);

	return 0;
}
Exemplo n.º 17
0
int main() {
  int r1, c1, r2, c2, kase = 0;
  while(scanf("%d%d%d%d%d%d", &R, &C, &r1, &c1, &r2, &c2) == 6 && R) {
    r1--; c1--; r2--; c2--;
    for(int r = 0; r < R; r++) {
      for(int c = 0; c < C-1; c++)
        grid[r][c][RIGHT] = grid[r][c+1][LEFT] = readint();
      if(r != R-1) for(int c = 0; c < C; c++)
        grid[r][c][DOWN] = grid[r+1][c][UP] = readint();
    }
    solver.init(R*C*5+1);

    n = 0;
    memset(id, 0, sizeof(id));

    // 源点出发的边
    for(int dir = 0; dir < 4; dir++) if(cango(r1, c1, dir)) {
       solver.AddEdge(0, ID(r1+dr[dir], c1+dc[dir], dir), grid[r1][c1][dir]*2); // 开始走下去
       solver.AddEdge(0, ID(r1+dr[dir], c1+dc[dir], 4), grid[r1][c1][dir]*2); // 走一步停下来
    }

    // 计算每个状态(r,c,dir)的后继状态
    for(int r = 0; r < R; r++)
      for(int c = 0; c < C; c++) {
        for(int dir = 0; dir < 4; dir++) if(cango(r, c, inv[dir])) {
          solver.AddEdge(ID(r, c, dir), ID(r, c, 4), grid[r][c][inv[dir]]); // 停下来!
          if(cango(r, c, dir))
            solver.AddEdge(ID(r, c, dir), ID(r+dr[dir], c+dc[dir], dir), grid[r][c][dir]); // 继续走
        }
        for(int dir = 0; dir < 4; dir++) if(cango(r, c, dir)) {
          solver.AddEdge(ID(r, c, 4), ID(r+dr[dir], c+dc[dir], dir), grid[r][c][dir]*2); // 重新开始走
          solver.AddEdge(ID(r, c, 4), ID(r+dr[dir], c+dc[dir], 4), grid[r][c][dir]*2); // 走一步停下来
        }
      }

    // 跑dijkstra
    solver.dijkstra(0);

    // 找最优解
    int ans = solver.d[ID(r2, c2, 4)];

    printf("Case %d: ", ++kase);
    if(ans == INF) printf("Impossible\n"); else printf("%d\n", ans);
  }
  return 0;
}
Exemplo n.º 18
0
bool TiledMapLayer::init()
{
    if (Layer::init()) {
        
        auto map = TMXTiledMap::create("tiledmap/TestMap.tmx");
        map->setAnchorPoint(Vec2(0.0f, 0.0f));
        map->setPosition(0, 0);
        this->addChild(map);
        
        
        auto mapLayer = map->getLayer("layer1");
        
        Size maxSize = mapLayer->getLayerSize();
        CCLOG("maplayer maxwidth %f maxheight %f" , maxSize.width,maxSize.height);
        
        mapGraph = new GridMap((int)maxSize.width,(int)maxSize.height);
        
        for (int row = 0; row < maxSize.width; row++) {
            for (int col = 0; col < maxSize.height; col++) {
                int gid = mapLayer->getTileGIDAt(Vec2(row,col));
                printf(" %d",gid);
                
                if (gid == 10) {
                    mapGraph->setGridVertexType(row, col, vertex_vertex);
                }
            }
            printf("\n");
        }
        
        Dijkstra dij;
        dij.Execute(*mapGraph, 10, 39 * ID_PARA + 13);
        Vertex * vertex = mapGraph->getVertex(39, 13);
        

//        AStar dij;
//        dij.Execute(*mapGraph, 10, 39 * ID_PARA + 13);
//        Vertex * vertex = mapGraph->getVertex(39, 13);
        
        printf("path tree length %lld \n", dij.pathTree.size());
        
        
//        for (auto it = dij.pathTree.find(vertex) , end = dij.pathTree.end(); it->second != 0&& it != end ; it= dij.pathTree.find(it->second)) {
//            mapLayer->setTileGID(31, Vec2(vertex->getX(), vertex->getY()));
//            vertex = it->second;
//        }
        
        auto end = dij.pathTree.end();
        while (vertex != nullptr) {
            mapLayer->setTileGID(31, Vec2(vertex->getX(), vertex->getY()));
            auto it = dij.pathTree.find(vertex);
            if (it != end && it->second != nullptr) {
                vertex = it->second;
            }else{
                vertex = nullptr;
            }
        }
        
        auto dispatcher = Director::getInstance()->getEventDispatcher();
        auto listener = EventListenerTouchOneByOne::create();
        
        listener->onTouchBegan = CC_CALLBACK_2(TiledMapLayer::onTouchBegan, this);
        listener->onTouchMoved = CC_CALLBACK_2(TiledMapLayer::onTouchMoved, this);
        listener->onTouchEnded = CC_CALLBACK_2(TiledMapLayer::onTouchEnded, this);
        dispatcher->addEventListenerWithSceneGraphPriority(listener, this);
        
        return true;
    }
    
    return false;
}
Exemplo n.º 19
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    setWindowTitle("Map Path Simulator");
    ui->mapa->setPixmap(QPixmap(":/Images/mapa.png"));
    layout = new QVBoxLayout(this);
    //for(int i = 0; i < 54; i++)
    //{
        //label = new QLabel("hola");
        //QString hola;
        //hola.append("hola");
        //label->setText(hola);
        //layout->addWidget(label);
    //}
    ui->scrollAreaWidgetContents->setLayout(layout);

    Nodo * nodos[54];

    nodos[0]=new Nodo("Santa Fe", 0);
    nodos[1]=new Nodo("San Jorge",1);
    nodos[2]=new Nodo("Nueva Ocotepeque", 2);
    nodos[3]=new Nodo("Copan Ruinas",3);
    nodos[4]=new Nodo("Santa Rosa de Copan", 4);
    nodos[5]=new Nodo("Florida", 5);
    nodos[6]=new Nodo("Gracias", 6);
    nodos[7]=new Nodo("Belen", 7);
    nodos[8]=new Nodo("San Andres", 8);
    nodos[9]=new Nodo("Trinidad", 9);
    nodos[10]=new Nodo("Ilama", 10);
    nodos[11]=new Nodo("Santa Barbara", 11);
    nodos[12]=new Nodo("La Esperanza", 12);
    nodos[13]=new Nodo("Dolores", 13);
    nodos[14]=new Nodo("San Antonio", 14);
    nodos[15]=new Nodo("Puerto Cortes", 15);
    nodos[16]=new Nodo("San Pedro Sula", 16);
    nodos[17]=new Nodo("Santa Cruz de Yojoa", 17);
    nodos[18]=new Nodo("Minas de Oro", 18);
    nodos[19]=new Nodo("Taulabe", 19);
    nodos[20]=new Nodo("Comayagua", 20);
    nodos[21]=new Nodo("La Paz", 21);
    nodos[22]=new Nodo("Santa Maria", 22);
    nodos[23]=new Nodo("Cabanas", 23);
    nodos[24]=new Nodo("Tela", 24);
    nodos[25]=new Nodo("Esparta", 25);
    nodos[26]=new Nodo("La Ceiba", 26);
    nodos[27]=new Nodo("El Progreso", 27);
    nodos[28]=new Nodo("Yoro", 28);
    nodos[29]=new Nodo("Olanchito", 29);
    nodos[30]=new Nodo("San Ignacio", 30);
    nodos[31]=new Nodo("San Juan de Flores", 31);
    nodos[32]=new Nodo("Tegucigalpa", 32);
    nodos[33]=new Nodo("Caridad", 33);
    nodos[34]=new Nodo("Nacaome", 34);
    nodos[35]=new Nodo("Amapala", 35);
    nodos[36]=new Nodo("San Isidro", 36);
    nodos[37]=new Nodo("Choluteca", 37);
    nodos[38]=new Nodo("El Triunfo",38);
    nodos[39]=new Nodo("Soledad", 39);
    nodos[40]=new Nodo("Yuscaran", 40);
    nodos[41]=new Nodo("Danli", 41);
    nodos[42]=new Nodo("Juticalpa", 42);
    nodos[43]=new Nodo("San Esteban", 43);
    nodos[44]=new Nodo("Catacamas", 44);
    nodos[45]=new Nodo("Balfate", 45);
    nodos[46]=new Nodo("Trujillo", 46);
    nodos[47]=new Nodo("Iriona", 47);
    nodos[48]=new Nodo("Brus Laguna", 48);
    nodos[49]=new Nodo("Ahuas", 49);
    nodos[50]=new Nodo("Puerto Lempira", 50);
    nodos[51]=new Nodo("Utila", 51);
    nodos[52]=new Nodo("Roatan", 52);
    nodos[53]=new Nodo("Guanaja", 53);

    nodos[0]->addArista(new Arista(2, 12.023));

    nodos[1]->addArista(new Arista(2, 33.386));
    nodos[1]->addArista(new Arista(4, 93.037));

    nodos[2]->addArista(new Arista(0, 12.023));
    nodos[2]->addArista(new Arista(1, 33.386));

    nodos[3]->addArista(new Arista(4, 71.853));
    nodos[3]->addArista(new Arista(5, 53.509));

    nodos[4]->addArista(new Arista(1, 93.037));
    nodos[4]->addArista(new Arista(3, 71.853));
    nodos[4]->addArista(new Arista(5, 53.802));
    nodos[4]->addArista(new Arista(6, 47.190));

    nodos[5]->addArista(new Arista(3, 53.509));
    nodos[5]->addArista(new Arista(4, 53.802));
    nodos[5]->addArista(new Arista(9, 100.935));

    nodos[6]->addArista(new Arista(4, 47.190));
    nodos[6]->addArista(new Arista(7, 17.279));

    nodos[7]->addArista(new Arista(6, 17.279));
    nodos[7]->addArista(new Arista(12, 63.263));

    nodos[8]->addArista(new Arista(13, 35.946));
    nodos[8]->addArista(new Arista(14, 89.514));

    nodos[9]->addArista(new Arista(5, 100.935));
    nodos[9]->addArista(new Arista(10, 14.955));
    nodos[9]->addArista(new Arista(16, 73.837));

    nodos[10]->addArista(new Arista(9, 14.955));
    nodos[10]->addArista(new Arista(11, 18.0));

    nodos[11]->addArista(new Arista(10, 18.0));
    nodos[11]->addArista(new Arista(19, 60.4));

    nodos[12]->addArista(new Arista(7, 63.263));
    nodos[12]->addArista(new Arista(13, 45.453));
    nodos[12]->addArista(new Arista(22, 61.248));

    nodos[13]->addArista(new Arista(8, 35.946));
    nodos[13]->addArista(new Arista(12, 45.453));
    nodos[13]->addArista(new Arista(14, 67.302));

    nodos[14]->addArista(new Arista(8, 89.514));
    nodos[14]->addArista(new Arista(13, 67.302));

    nodos[15]->addArista(new Arista(16, 51.125));

    nodos[16]->addArista(new Arista(9, 14.955));
    nodos[16]->addArista(new Arista(15, 51.125));
    nodos[16]->addArista(new Arista(27, 30.536));

    nodos[17]->addArista(new Arista(19, 45.377));
    nodos[17]->addArista(new Arista(27, 56.686));

    nodos[18]->addArista(new Arista(28, 87.2));

    nodos[19]->addArista(new Arista(11, 60.4));
    nodos[19]->addArista(new Arista(17, 45.377));
    nodos[19]->addArista(new Arista(20, 58.6));

    nodos[20]->addArista(new Arista(19, 58.6));
    nodos[20]->addArista(new Arista(21, 23.7));
    nodos[20]->addArista(new Arista(32, 89.9));

    nodos[21]->addArista(new Arista(20, 23.7));
    nodos[21]->addArista(new Arista(22, 54.3));

    nodos[22]->addArista(new Arista(12, 61.248));
    nodos[22]->addArista(new Arista(21, 54.3));
    nodos[22]->addArista(new Arista(23, 46.883));

    nodos[23]->addArista(new Arista(22, 46.883));

    nodos[24]->addArista(new Arista(27, 67.039));
    nodos[24]->addArista(new Arista(25, 47.602));

    nodos[25]->addArista(new Arista(24, 47.602));
    nodos[25]->addArista(new Arista(26, 81.709));

    nodos[26]->addArista(new Arista(25, 81.709));
    nodos[26]->addArista(new Arista(45, 47.762));
    nodos[26]->addArista(new Arista(52, 67.48));

    nodos[27]->addArista(new Arista(16, 30.536));
    nodos[27]->addArista(new Arista(17, 56.686));
    nodos[27]->addArista(new Arista(24, 67.039));
    nodos[27]->addArista(new Arista(28, 131));

    nodos[28]->addArista(new Arista(18, 87.2));
    nodos[28]->addArista(new Arista(27, 131));
    nodos[28]->addArista(new Arista(29, 107));
    nodos[28]->addArista(new Arista(30, 119));

    nodos[29]->addArista(new Arista(28, 107));
    nodos[29]->addArista(new Arista(45, 90.834));

    nodos[30]->addArista(new Arista(28, 119));
    nodos[30]->addArista(new Arista(31, 68.150));
    nodos[30]->addArista(new Arista(42, 154.583));

    nodos[31]->addArista(new Arista(30, 68.150));
    nodos[31]->addArista(new Arista(32, 51.190));

    nodos[32]->addArista(new Arista(20, 89.9));
    nodos[32]->addArista(new Arista(31, 51.190));
    nodos[32]->addArista(new Arista(34, 104.026));
    nodos[32]->addArista(new Arista(40, 67.453));

    nodos[33]->addArista(new Arista(34, 63.920));

    nodos[34]->addArista(new Arista(32, 104.026));
    nodos[34]->addArista(new Arista(33, 63.920));
    nodos[34]->addArista(new Arista(35, 48.184));
    nodos[34]->addArista(new Arista(36, 36.191));
    nodos[34]->addArista(new Arista(37, 56.6));

    nodos[35]->addArista(new Arista(34, 48.184));

    nodos[36]->addArista(new Arista(34, 36.191));

    nodos[37]->addArista(new Arista(34, 56.6));
    nodos[37]->addArista(new Arista(38, 40.3));
    nodos[37]->addArista(new Arista(39, 46.4));

    nodos[38]->addArista(new Arista(37, 40.3));

    nodos[39]->addArista(new Arista(37, 46.4));

    nodos[40]->addArista(new Arista(32, 67.453));
    nodos[40]->addArista(new Arista(41, 63.925));

    nodos[41]->addArista(new Arista(40, 63.925));

    nodos[42]->addArista(new Arista(30, 154.583));
    nodos[42]->addArista(new Arista(43, 107.091));
    nodos[42]->addArista(new Arista(44, 44.010));

    nodos[43]->addArista(new Arista(42, 107.091));
    nodos[43]->addArista(new Arista(46, 125.806));
    nodos[43]->addArista(new Arista(47, 172.791));

    nodos[44]->addArista(new Arista(42, 44.010));

    nodos[45]->addArista(new Arista(26, 47.762));
    nodos[45]->addArista(new Arista(29, 90.834));
    nodos[45]->addArista(new Arista(46, 132.361));

    nodos[46]->addArista(new Arista(43, 125.806));
    nodos[46]->addArista(new Arista(45, 132.361));
    nodos[46]->addArista(new Arista(47, 124.621));

    nodos[47]->addArista(new Arista(43, 172.791));
    nodos[47]->addArista(new Arista(46, 124.621));
    nodos[47]->addArista(new Arista(48, 62.56));

    nodos[48]->addArista(new Arista(47, 62.56));
    nodos[48]->addArista(new Arista(49, 37.67));

    nodos[49]->addArista(new Arista(48, 37.67));
    nodos[49]->addArista(new Arista(50, 66.80));

    nodos[50]->addArista(new Arista(49, 66.80));

    nodos[51]->addArista(new Arista(52, 49.08));

    nodos[52]->addArista(new Arista(26, 67.48));
    nodos[52]->addArista(new Arista(51, 49.08));
    nodos[52]->addArista(new Arista(53, 70.96));

    nodos[53]->addArista(new Arista(52, 70.96));

    sps.setX(235);sps.setY(280-20);
    santacruzdeyojoa.setX(266);santacruzdeyojoa.setY(355-20);
    puertocortes.setX(258);puertocortes.setY(233-20);

    progreso.setX(275);progreso.setY(322-20);
    yoro.setX(370);yoro.setY(342-20);
    olanchito.setX(459);olanchito.setY(288-20);

    tela.setX(291);tela.setY(241-20);
    esparta.setX(352);esparta.setY(250-20);
    ceiba.setX(424);ceiba.setY(243-20);

    balfate.setX(507);balfate.setY(248-20);
    trujillo.setX(554);trujillo.setY(222-20);
    iriona.setX(683);iriona.setY(226-20);

    sanesteban.setX(595);sanesteban.setY(302-20);
    juticalpa.setX(490);juticalpa.setY(377-20);
    catacamas.setX(630);catacamas.setY(427-20);

    danli.setX(493);danli.setY(511-20);
    soledad.setX(378);soledad.setY(586-20);
    yuscaran.setX(415);yuscaran.setY(533-20);

    sanisidro.setX(342);sanisidro.setY(582-20);
    choluteca.setX(360);choluteca.setY(632-20);
    eltriunfo.setX(389);eltriunfo.setY(668-20);

    nacaome.setX(316);nacaome.setY(598-20);
    amapala.setX(289);amapala.setY(638-20);
    caridad.setX(287);caridad.setY(559-20);

    santamaria.setX(247);santamaria.setY(498-20);
    lapaz.setX(287);lapaz.setY(473-20);
    cabanas.setX(240);cabanas.setY(527-20);

    dolores.setX(192);dolores.setY(490-20);
    laesperanza.setX(210);laesperanza.setY(476-20);
    sanantonio.setX(167);sanantonio.setY(536-20);

    sanandres.setX(173);sanandres.setY(502-20);
    gracias.setX(151);gracias.setY(431-20);
    belen.setX(158);belen.setY(451-20);

    sanjorge.setX(71);sanjorge.setY(427-20);
    ocotepeque.setX(56);ocotepeque.setY(451-20);
    santafe.setX(36);santafe.setY(450-20);

    santarosadecopan.setX(118);santarosadecopan.setY(398-20);
    florida.setX(108);florida.setY(339-20);
    copanruinas.setX(69);copanruinas.setY(381-20);

    trinidad.setX(195);trinidad.setY(312-20);
    santabarbara.setX(203);santabarbara.setY(375-20);
    ilama.setX(192);ilama.setY(338-20);

    taulabe.setX(241);taulabe.setY(405-20);
    comayagua.setX(295);comayagua.setY(455-20);
    minasdeoro.setX(305);minasdeoro.setY(366-20);

    sanignacio.setX(382);sanignacio.setY(387-20);
    sanjuandeflores.setX(411);sanjuandeflores.setY(476-20);
    tegucigalpa.setX(358);tegucigalpa.setY(510-20);

    roatan.setX(457);roatan.setY(155-20);
    utila.setX(399);utila.setY(192-20);
    guanaja.setX(557);guanaja.setY(132-20);

    bruslaguna.setX(766);bruslaguna.setY(246-20);
    puertolempira.setX(880);puertolempira.setY(323-20);
    ahuas.setX(799);ahuas.setY(279-20);

    for(int i = 0; i < 54; i++)
    {
        //QString temp = QString(nodos[i]->ciudad);
        ui->DBsrc->addItem(QString::fromStdString(nodos[i]->ciudad));
        ui->DBdest->addItem(QString::fromStdString(nodos[i]->ciudad));
    }

    for(int i = 0; i < 54; i++)
    {
        dijkstra.agregarNodo(nodos[i]);
        floyd.agregarNodo(nodos[i]);
        kruskal.addNodo(nodos[i]);
    }

}