| 440 | } |
| 441 | |
| 442 | void QueryGraph_MergeGraphs |
| 443 | ( |
| 444 | QueryGraph *to, |
| 445 | QueryGraph *from |
| 446 | ) { |
| 447 | uint node_count = QueryGraph_NodeCount(from); |
| 448 | uint edge_count = QueryGraph_EdgeCount(from); |
| 449 | |
| 450 | for(uint i = 0; i < node_count; i++) { |
| 451 | QGNode *n = from->nodes[i]; |
| 452 | // if the entity already exists in the "to" graph, do nothing |
| 453 | // we could have more complex logic to merge entity data, but this is not |
| 454 | // currently necessary as this logic only benefits toString calls like EXPLAIN |
| 455 | if(QueryGraph_GetNodeByAlias(to, n->alias)) continue; |
| 456 | // new entity, clone and add it |
| 457 | QueryGraph_AddNode(to, QGNode_Clone(n)); |
| 458 | } |
| 459 | |
| 460 | for(uint i = 0; i < edge_count; i++) { |
| 461 | QGEdge *e = from->edges[i]; |
| 462 | // if the entity already exists in the "to" graph, do nothing |
| 463 | // we could have more complex logic to merge entity data, but this is not |
| 464 | // currently necessary as this logic only benefits toString calls like EXPLAIN |
| 465 | if(QueryGraph_GetEdgeByAlias(to, e->alias)) continue; |
| 466 | |
| 467 | // retrieve the edge's endpoints in the "to" graph |
| 468 | QGNode *src = QueryGraph_GetNodeByAlias(to, e->src->alias); |
| 469 | QGNode *dest = QueryGraph_GetNodeByAlias(to, e->dest->alias); |
| 470 | // clone and add the unmatched edge |
| 471 | QGEdge *clone_edge = QGEdge_Clone(e); |
| 472 | QueryGraph_ConnectNodes(to, src, dest, clone_edge); |
| 473 | } |
| 474 | } |
| 475 | |
| 476 | QGNode *QueryGraph_GetNodeByAlias |
| 477 | ( |
no test coverage detected