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; +}