diff --git a/include/r3.h b/include/r3.h index c97e7c6..0cb33b3 100644 --- a/include/r3.h +++ b/include/r3.h @@ -39,6 +39,7 @@ typedef struct _route route; struct _node { edge ** edges; route ** routes; + edge * parent_edge; uint32_t edge_len; uint32_t edge_cap; uint32_t route_len; @@ -60,7 +61,6 @@ struct _node { void * data; uint8_t endpoint; - }; struct _edge { diff --git a/src/edge.c b/src/edge.c index dd9e813..f373ea4 100644 --- a/src/edge.c +++ b/src/edge.c @@ -30,6 +30,9 @@ edge * r3_edge_create(char * pattern, int pattern_len, node * child) { e->pattern_len = pattern_len; e->child = child; + // update childs parent edge + child->parent_edge = e; + // default stats e->hits = 0; e->score = 0; diff --git a/src/node.c b/src/node.c index 302c20e..a2e2a17 100644 --- a/src/node.c +++ b/src/node.c @@ -51,6 +51,8 @@ node * r3_tree_create(int cap) { n->edge_len = 0; n->edge_cap = cap; + n->parent_edge = NULL; + n->routes = NULL; n->route_len = 0; n->route_cap = 0; @@ -380,6 +382,8 @@ node * r3_node_create() { n->edge_len = 0; n->edge_cap = 0; + n->parent_edge = NULL; + n->routes = NULL; n->route_len = 0; n->route_cap = 0; diff --git a/tests/bench_str.csv b/tests/bench_str.csv index 4a9cfab..5ce3653 100644 --- a/tests/bench_str.csv +++ b/tests/bench_str.csv @@ -444,3 +444,4 @@ 1400681414,10832905.89 1400685490,13185955.87 1400748100,12609470.07 +1400748288,13317009.48