-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefinition.h
137 lines (83 loc) · 2.36 KB
/
definition.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#ifndef DEFINITION__H__
#define DEFINITION__H__
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#define STRLEN 1024
#define N 10
#define HASH 5
#define HASHLEN 200
/************* HASH STRUCTS ****************/
typedef struct hash_nodes
{
int next_available;
int* hash_array;
int size;
}hash_nodes;
typedef struct hash_table
{
hash_nodes* hash_table;
}hash_table;
/******************************************/
typedef struct indexStruct
{
int offset;
int tail;
int neighbor_num;
int cc;
int visited;
int bfs[2];
hash_table* table;
}indexStruct;
typedef struct NodeIndex
{
indexStruct* index_array;
int size;
}NodeIndex;
typedef struct list_node
{
uint32_t neighbor[N]; //the ids of the neighbor nodes
uint32_t edgeProperty[N]; //property for each edge
int nextListNode;
int emptyNeighborPos;
}list_node;
typedef struct Buffer
{
list_node* buffer_array;
int next_available_ba;
int size;
}Buffer;
/*******************FUNCTIONS***********************/
NodeIndex* createNodeIndex();
void IndexArrayInit(NodeIndex*, int);
Buffer* createBuffer();
void BufferArrayInit(Buffer*, int);
void ListNodeInit(list_node*);
/****************************************************/
void print_index_array(NodeIndex*, int );
void print_buffer(Buffer*, int);
int insertNode(NodeIndex*, Buffer*, uint32_t , uint32_t );
int insertEdge(Buffer* , NodeIndex*, int , uint32_t , uint32_t, int* );
/*****************DELETING STRUCTURE*****************/
int delete_structure(NodeIndex*,NodeIndex* , Buffer*, Buffer*);
int destroyBuffer(Buffer*);
int destroyNodeIndex1(NodeIndex*);
int destroyNodeIndex2(NodeIndex*);
/****************************************************/
int getListHead(NodeIndex*, int );
/**************************************************/
int insertEdgeHash(Buffer* , int , uint32_t , uint32_t , int* );
/*****************UNIT TESTING*****************/
int testInput();
int testMemory(Buffer* , Buffer*, NodeIndex*, NodeIndex*);
void edges_num_set(int ,int ,NodeIndex* );
/****************HASH FUNCTIONS********************/
int hash_fun(int , int);
hash_table* hash_init(hash_table*);
int hash_add_file(int , int , hash_table**);
int hash_add_query(int , int , hash_table**);
void delete_hash(hash_table*);
/**************************************************/
#endif