rework: changed to basic implementation for dijkstra

This commit is contained in:
2026-05-06 19:58:33 -06:00
parent 0241829777
commit 94cfb10960
2 changed files with 17 additions and 6 deletions

View File

@@ -9,6 +9,8 @@ typedef struct Edge Edge;
typedef enum {
GRAPH_OK,
GRAPH_BAD_ALLOC,
GRAPH_NOT_FOUND,
} GraphErr ;
typedef enum {
@@ -16,5 +18,18 @@ typedef enum {
GRAPH_UNDIRECTED,
} GraphType;
Graph *graph_create(GraphType type);
GraphErr graph_destroy(Graph *graph);
GraphErr graph_add_vertex(Graph *graph);
GraphErr graph_connect_vertex(
Graph *graph,
size_t node1,
size_t node2,
size_t weight);
GraphErr graph_vertex_count(size_t *out);
GraphErr graph_get_vertex(Graph *graph, size_t index, Vertex *out);
#endif

View File

@@ -4,19 +4,15 @@
#include <stdint.h>
struct Vertex {
void *data;
ArrayList *edges;
};
struct Edge {
size_t *to;
intmax_t weight;
size_t to;
size_t weight;
};
struct Graph {
ArrayList *vertices;
GraphType type;
int (*cmp)(const void*, const void*);
void (*free_data)(void*);
};