clones path from 'qg' into 'graph'
| 202 | |
| 203 | // clones path from 'qg' into 'graph' |
| 204 | static void _QueryGraph_ExtractPath |
| 205 | ( |
| 206 | const QueryGraph *qg, |
| 207 | QueryGraph *graph, |
| 208 | const cypher_astnode_t *path |
| 209 | ) { |
| 210 | |
| 211 | // validate input |
| 212 | ASSERT(qg != NULL && graph != NULL && path != NULL); |
| 213 | |
| 214 | const char *alias; |
| 215 | const cypher_astnode_t *ast_node; |
| 216 | uint nelems = cypher_ast_pattern_path_nelements(path); |
| 217 | |
| 218 | // introduce nodes to graph |
| 219 | // nodes are at even indices |
| 220 | for(uint i = 0; i < nelems; i += 2) { |
| 221 | ast_node = cypher_ast_pattern_path_get_element(path, i); |
| 222 | _QueryGraph_ExtractNode(qg, graph, ast_node); |
| 223 | } |
| 224 | |
| 225 | // introduce edges to graph |
| 226 | // edges are at odd indices |
| 227 | for(uint i = 1; i < nelems; i += 2) { |
| 228 | // retrieve the QGNode corresponding to the node left of this edge |
| 229 | const cypher_astnode_t *l_node = cypher_ast_pattern_path_get_element(path, i - 1); |
| 230 | const char *l_alias = AST_ToString(l_node); |
| 231 | QGNode *left = QueryGraph_GetNodeByAlias(graph, l_alias); |
| 232 | |
| 233 | // retrieve the QGNode corresponding to the node right of this edge |
| 234 | const cypher_astnode_t *r_node = cypher_ast_pattern_path_get_element(path, i + 1); |
| 235 | const char *r_alias = AST_ToString(r_node); |
| 236 | QGNode *right = QueryGraph_GetNodeByAlias(graph, r_alias); |
| 237 | |
| 238 | ast_node = cypher_ast_pattern_path_get_element(path, i); |
| 239 | _QueryGraph_ExtractEdge(qg, graph, left, right, ast_node); |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | QueryGraph *QueryGraph_New |
| 244 | ( |
no test coverage detected