From 8b6ec8ce2ef4570728976fd18ffa0746ff556143 Mon Sep 17 00:00:00 2001 From: laentropia Date: Wed, 6 May 2026 20:08:36 -0600 Subject: [PATCH] addtition: graph create --- src/graph.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/graph.c b/src/graph.c index 6a2d40c..c036189 100644 --- a/src/graph.c +++ b/src/graph.c @@ -2,6 +2,7 @@ #include "arraylist.h" #include #include +#include struct Vertex { ArrayList *edges; @@ -16,3 +17,20 @@ struct Graph { ArrayList *vertices; GraphType type; }; + +Graph *graph_create(GraphType type) { + Graph *graph = malloc(sizeof(Graph)); + if (graph == NULL) { + return NULL; + } + + graph->type = type; + graph->vertices = arraylist_init(64, sizeof(Vertex)); + + if (graph->vertices == NULL) { + free(graph); + return NULL; + } + + return graph; +}