-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraph.h
35 lines (31 loc) · 1.08 KB
/
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
32
33
34
35
#ifndef GRAPH_H
#define GRAPH_H
#include <stdlib.h>
#include "list.h"
#include "set.h"
typedef struct AdjList_
{
void *vertex;
Set adjacent;
}AdjList;
typedef struct Graph_
{
int vcount;
int ecount;
int (*match)(const void *key1,const void *key2);
void (*destroy)(void *data);
List adjlists;
}Graph;
typedef enum VertexColor_ {white,gray,black} VertexColor;
void graph_init(Graph *graph,int(*match)(const void *key1,const void *key2),void (*destroy)(void *data));
void graph_destroy(Graph *graph);
int graph_ins_vertex(Graph *graph,const void *data);
int graph_ins_edge(Graph *graph,const void *data1,const void *data2);
int graph_rem_vertex(Graph *graph,void **data);
int graph_rem_edge(Graph *graph,void *data1, void **data2);
int graph_adjlist(const Graph *graph,const void *data,AdjList **adjlist);
int graph_is_adjacent(const Graph *graph,const void *data1,const void *data2);
#define graph_adjlists(graph) ((graph)->adjlists)
#define graph_vcount(graph) ((graph)->vcount)
#define graph_ecount(graph) ((graph)->ecount)
#endif // GRAPH_H