blob: 0467e8b08244576ba421569f42b28bfa64c566a3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#include "graph.h"
#include <stdlib.h>
#include <stdio.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 < 128; ++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;
}
|