aboutsummaryrefslogtreecommitdiff
path: root/sem3/algo/mm12/graph.h
diff options
context:
space:
mode:
authorJulian T <julian@jtle.dk>2020-02-11 12:24:56 +0100
committerJulian T <julian@jtle.dk>2020-02-11 12:24:56 +0100
commit6db1a2cdd3b96731f2e092d55d8c2136eabc52d0 (patch)
tree2be8fae8ce82d708ed9f00f376dda14420850e80 /sem3/algo/mm12/graph.h
parent57305119e05559c1c37e903aef89cd43f44c42c9 (diff)
Rename and cleanup
Diffstat (limited to 'sem3/algo/mm12/graph.h')
-rw-r--r--sem3/algo/mm12/graph.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/sem3/algo/mm12/graph.h b/sem3/algo/mm12/graph.h
new file mode 100644
index 0000000..e957c4d
--- /dev/null
+++ b/sem3/algo/mm12/graph.h
@@ -0,0 +1,34 @@
+#ifndef GRAPH_H_
+#define GRAPH_H_
+
+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 dist;
+ 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_