addition: Base for implementation

This commit is contained in:
2026-05-06 11:29:28 -06:00
parent 574bd1bc13
commit 0241829777
5 changed files with 48 additions and 1 deletions

1
.gitignore vendored
View File

@@ -16,6 +16,7 @@ Testing/
compile_commands.json compile_commands.json
../compile_commands.json ../compile_commands.json
build/compile_commands.json build/compile_commands.json
cmake
# Make / Ninja # Make / Ninja
Makefile Makefile

View File

@@ -11,6 +11,14 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
option(GRAPH_BUILD_TESTS "Build arraylist tests" OFF) option(GRAPH_BUILD_TESTS "Build arraylist tests" OFF)
option(GRAPH_ENABLE_SANITIZERS "Enable sanitizers for tests" ON) 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 # Library
# ------------------------ # ------------------------
@@ -39,6 +47,10 @@ target_link_libraries(graph_example
graph graph
) )
target_link_libraries(graph
PUBLIC arraylist
)
# ------------------------ # ------------------------
# Testing # Testing
# ------------------------ # ------------------------

View File

@@ -1,6 +1,20 @@
#ifndef GRAPH_H #ifndef GRAPH_H
#define GRAPH_H #define GRAPH_H
#include <stdlib.h>
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 #endif

View File

@@ -1 +1,22 @@
#include "graph.h" #include "graph.h"
#include "arraylist.h"
#include <inttypes.h>
#include <stdint.h>
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*);
};

View File

@@ -1,5 +1,4 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
int main(void) { int main(void) {
return EXIT_SUCCESS; return EXIT_SUCCESS;