| 536 | } |
| 537 | |
| 538 | QueryGraph *QueryGraph_Clone |
| 539 | ( |
| 540 | const QueryGraph *qg |
| 541 | ) { |
| 542 | uint node_count = QueryGraph_NodeCount(qg); |
| 543 | uint edge_count = QueryGraph_EdgeCount(qg); |
| 544 | QueryGraph *clone = QueryGraph_New(node_count, edge_count); |
| 545 | |
| 546 | // clone nodes |
| 547 | for(uint i = 0; i < node_count; i++) { |
| 548 | // clones node without its edges |
| 549 | QGNode *n = QGNode_Clone(qg->nodes[i]); |
| 550 | QueryGraph_AddNode(clone, n); |
| 551 | } |
| 552 | |
| 553 | // clone edges |
| 554 | for(uint i = 0; i < edge_count; i++) { |
| 555 | QGEdge *e = qg->edges[i]; |
| 556 | QGNode *src = QueryGraph_GetNodeByAlias(clone, e->src->alias); |
| 557 | QGNode *dest = QueryGraph_GetNodeByAlias(clone, e->dest->alias); |
| 558 | ASSERT(src != NULL && dest != NULL); |
| 559 | |
| 560 | QGEdge *clone_edge = QGEdge_Clone(e); |
| 561 | QueryGraph_ConnectNodes(clone, src, dest, clone_edge); |
| 562 | } |
| 563 | |
| 564 | return clone; |
| 565 | } |
| 566 | |
| 567 | QGNode *QueryGraph_RemoveNode |
| 568 | ( |