aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 0000000..07e629b
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,55 @@
+#include "graph.h"
+#include "queue.h"
+#include "stack.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+#define GRAPH_SIZE 5
+
+int main() {
+ Queue *queue = queueAlloc();
+ queueAdd(queue, 1);
+ queueAdd(queue, 2);
+ queueAdd(queue, 3);
+ queueAdd(queue, 4);
+ queueAdd(queue, 5);
+ queueAdd(queue, 6);
+ printf("%d\n", queuePop(queue));
+ printf("%d\n", queuePop(queue));
+ printf("%d\n", queuePop(queue));
+ printf("%d\n", queuePop(queue));
+ printf("%d\n", queuePop(queue));
+ printf("%d\n", queuePop(queue));
+ queueFree(queue);
+ Stack *stack = stackAlloc();
+ stackAdd(stack, 1);
+ stackAdd(stack, 2);
+ stackAdd(stack, 3);
+ stackAdd(stack, 4);
+ stackAdd(stack, 5);
+ stackAdd(stack, 6);
+ printf("%d\n", stackPop(stack));
+ printf("%d\n", stackPop(stack));
+ printf("%d\n", stackPop(stack));
+ printf("%d\n", stackPop(stack));
+ printf("%d\n", stackPop(stack));
+ printf("%d\n", stackPop(stack));
+ stackFree(stack);
+
+ struct vertexList *graph = vertexAlloc(GRAPH_SIZE);
+ vertexAdd(graph, 0, 1);
+ vertexAdd(graph, 1, 2);
+ vertexAdd(graph, 1, 0);
+ vertexAdd(graph, 2, 3);
+ vertexAdd(graph, 3, 4);
+ vertexAdd(graph, 1, 4);
+
+ for (int j = 0; j < GRAPH_SIZE; j++) {
+ printf("%d:", j);
+ for (struct vertex *i = graph[j].first; i != NULL; i = i->next) {
+ printf(" %ld,", i->number);
+ }
+ printf("\n");
+ }
+}
+