blob: fbd867778ce817585f037e9c59e69ac5645d1053 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#include "graph.h"
#include <stdlib.h>
Vertex *vertex_initialize(char label) {
Vertex *item = malloc(sizeof(Vertex));
item->label = label;
return item;
};
Graph *graph_initialize(void) {
Graph *item = malloc(sizeof(Graph));
for (int i = 0; i < 256; ++i)
item->vertices[i] = NULL;
return item;
}
Vertex *graph_add_vertex(Graph *graph, char label) {
Vertex *item = vertex_initialize(label);
graph->vertices[(int)label] = item;
return item;
}
|