2026-05-06 09:45:22 -06:00
|
|
|
#include <stdlib.h>
|
2026-05-06 22:29:22 -06:00
|
|
|
#include <stdio.h>
|
|
|
|
|
#include "graph.h"
|
2026-05-06 09:45:22 -06:00
|
|
|
|
|
|
|
|
int main(void) {
|
2026-05-06 22:29:22 -06:00
|
|
|
Graph *graph = graph_create(GRAPH_UNDIRECTED);
|
|
|
|
|
|
2026-05-07 11:04:51 -06:00
|
|
|
graph_add_vertex(graph); // 0
|
|
|
|
|
graph_add_vertex(graph); // 1
|
|
|
|
|
graph_add_vertex(graph); // 2
|
|
|
|
|
graph_add_vertex(graph); // 3
|
|
|
|
|
graph_add_vertex(graph); // 4
|
|
|
|
|
graph_add_vertex(graph); // 5
|
|
|
|
|
graph_add_vertex(graph); // 6
|
|
|
|
|
graph_add_vertex(graph); // 7
|
2026-05-06 22:29:22 -06:00
|
|
|
|
2026-05-07 11:04:51 -06:00
|
|
|
graph_connect_vertex(graph, 0, 1, 5);
|
|
|
|
|
graph_connect_vertex(graph, 0, 2, 2);
|
|
|
|
|
graph_connect_vertex(graph, 1, 2, 1);
|
|
|
|
|
graph_connect_vertex(graph, 1, 3, 3);
|
|
|
|
|
graph_connect_vertex(graph, 1, 4, 12);
|
|
|
|
|
graph_connect_vertex(graph, 2, 3, 7);
|
|
|
|
|
graph_connect_vertex(graph, 2, 5, 10);
|
|
|
|
|
graph_connect_vertex(graph, 3, 4, 2);
|
|
|
|
|
graph_connect_vertex(graph, 3, 5, 6);
|
|
|
|
|
graph_connect_vertex(graph, 4, 6, 1);
|
|
|
|
|
graph_connect_vertex(graph, 5, 6, 3);
|
|
|
|
|
graph_connect_vertex(graph, 5, 7, 5);
|
|
|
|
|
graph_connect_vertex(graph, 6, 7, 2);
|
2026-05-06 22:29:22 -06:00
|
|
|
|
|
|
|
|
DijkstraResult result;
|
|
|
|
|
graph_dijkstra(graph, 0, &result);
|
|
|
|
|
|
|
|
|
|
puts("Algoritmo de dijsktra");
|
|
|
|
|
graph_print(graph);
|
|
|
|
|
dijkstra_print_result(&result);
|
|
|
|
|
|
2026-05-06 09:45:22 -06:00
|
|
|
return EXIT_SUCCESS;
|
|
|
|
|
}
|