aboutsummaryrefslogtreecommitdiff
path: root/sem1/algo/workshop2/dfs/graph.h
diff options
context:
space:
mode:
authorJulian T <julian@jtle.dk>2019-11-21 11:41:24 +0100
committerJulian T <julian@jtle.dk>2019-11-21 11:41:24 +0100
commit9eccc3f2f3f03ffdd9d7b985fecf7222bb956df3 (patch)
tree4adbb3eee59f6fbecb1bca0ad297d5090c92a39a /sem1/algo/workshop2/dfs/graph.h
parent8a683b6e70de446d16b809fbcbf395153fc367b9 (diff)
Added dfs impl
Diffstat (limited to 'sem1/algo/workshop2/dfs/graph.h')
-rw-r--r--sem1/algo/workshop2/dfs/graph.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/sem1/algo/workshop2/dfs/graph.h b/sem1/algo/workshop2/dfs/graph.h
new file mode 100644
index 0000000..67ac1dc
--- /dev/null
+++ b/sem1/algo/workshop2/dfs/graph.h
@@ -0,0 +1,42 @@
+#ifndef GRAPH_H_
+#define GRAPH_H_
+
+#define COLOR_WHITE 0
+#define COLOR_GRAY 1
+#define COLOR_BLACK 2
+
+struct vertex_struct;
+
+// Linked list
+typedef struct edge_struct {
+ int weight;
+ struct vertex_struct *from;
+ struct vertex_struct *to;
+ // Linked list stuff
+ struct edge_struct *next;
+ struct edge_struct *prev;
+} edge_t;
+
+typedef struct vertex_struct {
+ char ref;
+ int color;
+
+ int dtime;
+ int ftime;
+
+ struct vertex_struct *p;
+ edge_t *adj;
+} vertex_t;
+
+typedef struct {
+ vertex_t *vertexes[128];
+
+} graph_t;
+
+int graph_to_dot(FILE *f, graph_t *g);
+int graph_print_adj(graph_t *g, char ref);
+void graph_edge(graph_t *g, char from, char to, int weight);
+edge_t *edge_next(graph_t *g, edge_t *e);
+vertex_t *vertex_next(graph_t *g, vertex_t *v);
+
+#endif // GRAPH_H_