MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / QueryGraph_MergeGraphs

Function QueryGraph_MergeGraphs

src/graph/query_graph.c:442–474  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

440}
441
442void 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
476QGNode *QueryGraph_GetNodeByAlias
477(

Callers 1

Calls 8

QueryGraph_NodeCountFunction · 0.85
QueryGraph_EdgeCountFunction · 0.85
QueryGraph_AddNodeFunction · 0.85
QGNode_CloneFunction · 0.85
QGEdge_CloneFunction · 0.85
QueryGraph_ConnectNodesFunction · 0.85

Tested by

no test coverage detected