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

Function Graph_GetEdgeRelation

src/graph/graph.c:572–619  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

570}
571
572RelationID Graph_GetEdgeRelation
573(
574 const Graph *g,
575 Edge *e
576) {
577 ASSERT(g);
578 ASSERT(e);
579
580 GrB_Info info;
581 RelationID rel = GRAPH_NO_RELATION;
582 EdgeID id = ENTITY_GET_ID(e);
583 NodeID src_id = Edge_GetSrcNodeID(e);
584 NodeID dest_id = Edge_GetDestNodeID(e);
585
586 // search for relation mapping matrix M, where M[dest,src] == edge ID
587 uint n = array_len(g->relations);
588 for(uint i = 0; i < n; i++) {
589 EdgeID edgeId = 0;
590 RG_Matrix M = Graph_GetRelationMatrix(g, i, false);
591 info = RG_Matrix_extractElement_UINT64(&edgeId, M, src_id, dest_id);
592 if(info != GrB_SUCCESS) continue;
593
594 if(SINGLE_EDGE(edgeId)) {
595 EdgeID curEdgeID = edgeId;
596 if(curEdgeID == id) {
597 Edge_SetRelationID(e, i);
598 rel = i;
599 break;
600 }
601 } else {
602 // multiple edges exists between src and dest
603 // see if given edge is one of them
604 EdgeID *edges = (EdgeID *)(CLEAR_MSB(edgeId));
605 int edge_count = array_len(edges);
606 for(int j = 0; j < edge_count; j++) {
607 if(edges[j] == id) {
608 Edge_SetRelationID(e, i);
609 rel = i;
610 break;
611 }
612 }
613 }
614 }
615
616 // we must be able to find edge relation
617 ASSERT(rel != GRAPH_NO_RELATION);
618 return rel;
619}
620
621void Graph_GetEdgesConnectingNodes
622(

Callers

nothing calls this directly

Calls 6

Edge_GetSrcNodeIDFunction · 0.85
Edge_GetDestNodeIDFunction · 0.85
array_lenFunction · 0.85
Graph_GetRelationMatrixFunction · 0.85
Edge_SetRelationIDFunction · 0.85

Tested by

no test coverage detected