forked from waynebhayes/BLANT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsyntheticDS.h
75 lines (61 loc) · 2.08 KB
/
syntheticDS.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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "uthash.h"
#include "graph.h"
#include "sets.h"
typedef struct keyvalue{
int key, value;
UT_hash_handle hh;
} KeyValue;
typedef struct dictionary{
KeyValue* hashTable;
} Dictionary;
typedef struct change{
int k, linenum, original, new;
} Change;
typedef struct revertstack{
int tos, size;
Change* space;
} RevertStack;
typedef struct int_tuple{
int nums[2];
} IntTuple;
typedef struct smallworld{
int make; // +1 for make more small world, 0 for do nothing, -1 for make less small world
int khop_interval;
int lowerHops, upperHops;
} SmallWorld;
typedef struct clustcoffstate{
int* histograms[2]; // stores num of elts in a bin
int histograms_size[2]; // stores num of bins
double histograms_bin_size[2]; // stores bin size/width
} ClustCoffState;
typedef struct gkstate{
long udotv, sq_length_u, sq_length_v;
} GKState;
// key:value hash helpers
int dictionary_create(Dictionary* dictionary);
int dictionary_get(Dictionary* dictionary, int key, int default_value);
void dictionary_set(Dictionary* dictionary, int key, int value);
KeyValue* getIterator(Dictionary* dictionary);
int getNext(KeyValue** iterator, int* key, int* value);
// revert stack helpers
int create_stack(RevertStack* stack, int size);
int init_stack(RevertStack* stack);
int push(RevertStack* stack, Change elt);
int pop(RevertStack* stack, Change* elt);
// math helpers
int getIntMedian(int* nums, int start, int end);
double getDoubleMedian(double* nums, int start, int end);
double PoissonDistribution(double l, int k);
// optimum histogram bin size
double getDoubleBinSize(int n, double localClustCoff[n], double* scratchspace);
int getIntegerBinSize(int n, int GDVcolumn[n], int* scratchspace);
// node selection helpers
int getRandomNodeAtHops(GRAPH* G, int src, int hops);
int getRandomConnectedNode(GRAPH* G, int src);
// k-hop helpers
void sampleKHop(GRAPH* G, Dictionary* khop, double quality, int nodesBySp[G->n]);
int compareKHopByMedian(Dictionary* khop[2], int medians[2], int maxKeys[2]);
void print_khop_sample(Dictionary* khop);