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

Function addIncomingNeighbors

src/procedures/proc_ss_paths.c:354–382  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

352}
353
354static void addIncomingNeighbors
355(
356 SingleSourceCtx *ctx,
357 LevelConnection *frontier,
358 uint32_t depth
359) {
360 EntityID frontierId = INVALID_ENTITY_ID;
361 if(depth > 1) frontierId = ENTITY_GET_ID(&frontier->edge);
362
363 // Get frontier neighbors.
364 for(int i = 0; i < ctx->relationCount; i++) {
365 Graph_GetNodeEdges(ctx->g, &frontier->node, GRAPH_EDGE_DIR_INCOMING, ctx->relationIDs[i], &ctx->neighbors);
366 }
367
368 // Add unvisited neighbors to next level.
369 uint32_t neighborsCount = array_len(ctx->neighbors);
370
371 _SingleSourceCtx_EnsureLevelArrayCap(ctx, depth, neighborsCount);
372 for(uint32_t i = 0; i < neighborsCount; i++) {
373 // Don't follow the frontier edge again.
374 if(frontierId == ENTITY_GET_ID(ctx->neighbors + i)) continue;
375 // Set the neighbor by following the edge in the correct directoin.
376 Node neighbor = GE_NEW_NODE();
377 Graph_GetNode(ctx->g, Edge_GetSrcNodeID(ctx->neighbors + i), &neighbor);
378 // Add the node and edge to the frontier.
379 _SingleSourceCtx_AddConnectionToLevel(ctx, depth, &neighbor, (ctx->neighbors + i));
380 }
381 array_clear(ctx->neighbors);
382}
383
384// traverse from the frontier node in the specified direction and add all encountered nodes and edges.
385static void addNeighbors

Callers 1

addNeighborsFunction · 0.70

Calls 6

Graph_GetNodeEdgesFunction · 0.85
array_lenFunction · 0.85
Graph_GetNodeFunction · 0.85
Edge_GetSrcNodeIDFunction · 0.85

Tested by

no test coverage detected