addition: dijkstar printing

This commit is contained in:
2026-05-06 22:29:22 -06:00
parent a20e77c09a
commit 19d1c2d984
4 changed files with 134 additions and 3 deletions

View File

@@ -1,5 +1,34 @@
#include <stdlib.h>
#include <stdio.h>
#include "graph.h"
int main(void) {
Graph *graph = graph_create(GRAPH_UNDIRECTED);
graph_add_vertex(graph);
graph_add_vertex(graph);
graph_add_vertex(graph);
graph_add_vertex(graph);
graph_add_vertex(graph);
graph_add_vertex(graph);
graph_connect_vertex(graph, 0, 1, 9);
graph_connect_vertex(graph, 0, 2, 4);
graph_connect_vertex(graph, 1, 2, 2);
graph_connect_vertex(graph, 1, 4, 3);
graph_connect_vertex(graph, 1, 3, 7);
graph_connect_vertex(graph, 2, 3, 1);
graph_connect_vertex(graph, 2, 4, 6);
graph_connect_vertex(graph, 3, 4, 4);
graph_connect_vertex(graph, 3, 5, 8);
graph_connect_vertex(graph, 4, 5, 2);
DijkstraResult result;
graph_dijkstra(graph, 0, &result);
puts("Algoritmo de dijsktra");
graph_print(graph);
dijkstra_print_result(&result);
return EXIT_SUCCESS;
}