forked from IshitaTakeshi/Graph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
graph.h
31 lines (26 loc) · 842 Bytes
/
graph.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef GRAPH_H
#define GRAPH_H
/* TODO create a type for vertices */
typedef struct node_t {
char label;
int n_neighbors;
struct node_t **neighbors; /* list of pointers of adjacent nodes */
/* TODO rename to distances */
double *weights;
} Node;
typedef struct graph_t {
int n_nodes;
struct node_t **nodes; /* list of pointers of nodes */
} Graph;
void free_graph(struct graph_t *graph);
Node *create_node(char label);
void connect(Node *node1, Node *node2);
void wconnect(Node *node1, Node *node2, double weight);
Graph *init_graph();
void add_node(Graph *graph, Node *node);
int are_same_nodes(Node *node1, Node *node2);
Node *get_node(Graph *graph, char label);
int node_exists(Graph *graph, char label);
void show_node(Node *node, int show_weight);
void show_graph(Graph *graph, int show_weight);
#endif