diff --git a/.gitignore b/.gitignore index 0bd57ed..cab31f3 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ Testing/ compile_commands.json ../compile_commands.json build/compile_commands.json +cmake # Make / Ninja Makefile diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f85221..8be934b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,14 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) option(GRAPH_BUILD_TESTS "Build arraylist tests" OFF) option(GRAPH_ENABLE_SANITIZERS "Enable sanitizers for tests" ON) +include(cmake/CPM.cmake) + +CPMAddPackage( + NAME arraylist + GIT_REPOSITORY https://laentropia-homelab.tail7368da.ts.net/laentropia/ArrayList.git + GIT_TAG main +) + # ------------------------ # Library # ------------------------ @@ -39,6 +47,10 @@ target_link_libraries(graph_example graph ) +target_link_libraries(graph + PUBLIC arraylist +) + # ------------------------ # Testing # ------------------------ diff --git a/include/graph.h b/include/graph.h index abd2930..ac244c9 100644 --- a/include/graph.h +++ b/include/graph.h @@ -1,6 +1,20 @@ #ifndef GRAPH_H #define GRAPH_H +#include + +typedef struct Graph Graph; +typedef struct Vertex Vertex; +typedef struct Edge Edge; + +typedef enum { + GRAPH_OK, +} GraphErr ; + +typedef enum { + GRAPH_DIRECTED, + GRAPH_UNDIRECTED, +} GraphType; #endif diff --git a/src/graph.c b/src/graph.c index e8b6b5e..cf53a7e 100644 --- a/src/graph.c +++ b/src/graph.c @@ -1 +1,22 @@ #include "graph.h" +#include "arraylist.h" +#include +#include + +struct Vertex { + void *data; + ArrayList *edges; +}; + +struct Edge { + size_t *to; + intmax_t weight; +}; + +struct Graph { + ArrayList *vertices; + GraphType type; + + int (*cmp)(const void*, const void*); + void (*free_data)(void*); +}; diff --git a/src/main.c b/src/main.c index 1de0591..24acc10 100644 --- a/src/main.c +++ b/src/main.c @@ -1,5 +1,4 @@ #include -#include int main(void) { return EXIT_SUCCESS;