diff --git a/include/graph.h b/include/graph.h index ac244c9..d242263 100644 --- a/include/graph.h +++ b/include/graph.h @@ -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 diff --git a/src/graph.c b/src/graph.c index cf53a7e..6a2d40c 100644 --- a/src/graph.c +++ b/src/graph.c @@ -4,19 +4,15 @@ #include 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*); };