-
Notifications
You must be signed in to change notification settings - Fork 0
/
lwmr_embeddingOperators.c
77 lines (58 loc) · 2.12 KB
/
lwmr_embeddingOperators.c
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
/*
* lwm_embeddingOperators.c
*
* Created on: Oct 28, 2016
* Author: pascal
*/
#include <stddef.h>
#include <stdlib.h>
#include "subtreeIsoUtils.h"
#include "iterativeSubtreeIsomorphism.h"
#include "importantSubtrees.h"
#include "localEasySubtreeIsomorphism.h"
#include "subtreeIsomorphismSampling.h"
#include "lwm_embeddingOperators.h"
// WRAPPERS FOR DIFFERENT ROOTED TREE EMBEDDING OPERATORS
/**
* Exact embedding Operator for
* tree pattern h
* forest transaction data
*/
struct SubtreeIsoDataStore rootedSubtreeComputationOperator(struct SubtreeIsoDataStore data, struct Graph* h, double importance, struct GraphPool* gp, struct ShallowGraphPool* sgp) {
(void)sgp; // unused
(void)importance; // unused
struct Vertex* rootEmbedding = NULL;
struct SubtreeIsoDataStore result = noniterativeRootedSubtreeCheck(data, h, &rootEmbedding, gp);
// if (result.foundIso) {
// // nasty hack to output information on embeddings found (for all patterns, not only frequent ones) to stdout
// fprintf(stdout, "emb %i %i %i\n", h->number, data.g->number, rootEmbedding->number);
// }
return result;
}
/**
* Randomized embedding operator for
* tree pattern h
* graph transaction data
*
* The algorithm repeats to try to embed a randomly rooted shuffled version of the tree h
* in some random place in the transaction graph. If it succeeds at some point, it returns 1.
* This is another example of an embedding operator with one-sided error.
*
* This variant sorts the neighbors of pattern vertex and transaction vertex by label and
* shuffles the blocks locally to obtain a maximum matching that is sampled uniformly at random
* from the set of all maximal matchings.
*
*/
struct SubtreeIsoDataStore rootedHopsOperator(struct SubtreeIsoDataStore data, struct Graph* h, double importance, struct GraphPool* gp, struct ShallowGraphPool* sgp) {
(void)sgp; // unused
struct SubtreeIsoDataStore result = {0};
result.g = data.g;
result.h = h;
for (int i=0; i<importance; ++i) {
result.foundIso = subtreeIsomorphismSamplerWithSampledMaximumMatching(data.g, h, gp, 0);
if (result.foundIso) {
break;
}
}
return result;
}