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

Function addOutgoingNeighbors

src/procedures/proc_sp_paths.c:329–357  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

327}
328
329static void addOutgoingNeighbors
330(
331 SinglePairCtx *ctx,
332 LevelConnection *frontier,
333 uint32_t depth
334) {
335 EntityID frontierId = INVALID_ENTITY_ID;
336 if(depth > 1) frontierId = ENTITY_GET_ID(&frontier->edge);
337
338 // Get frontier neighbors.
339 for(int i = 0; i < ctx->relationCount; i++) {
340 Graph_GetNodeEdges(ctx->g, &frontier->node, GRAPH_EDGE_DIR_OUTGOING, ctx->relationIDs[i], &ctx->neighbors);
341 }
342
343 // Add unvisited neighbors to next level.
344 uint32_t neighborsCount = array_len(ctx->neighbors);
345
346 _SinglePairCtx_EnsureLevelArrayCap(ctx, depth, neighborsCount);
347 for(uint32_t i = 0; i < neighborsCount; i++) {
348 // Don't follow the frontier edge again.
349 if(frontierId == ENTITY_GET_ID(ctx->neighbors + i)) continue;
350 // Set the neighbor by following the edge in the correct directoin.
351 Node neighbor = GE_NEW_NODE();
352 Graph_GetNode(ctx->g, Edge_GetDestNodeID(ctx->neighbors + i), &neighbor);
353 // Add the node and edge to the frontier.
354 _SinglePairCtx_AddConnectionToLevel(ctx, depth, &neighbor, (ctx->neighbors + i));
355 }
356 array_clear(ctx->neighbors);
357}
358
359static void addIncomingNeighbors
360(

Callers 1

addNeighborsFunction · 0.70

Calls 6

Graph_GetNodeEdgesFunction · 0.85
array_lenFunction · 0.85
Graph_GetNodeFunction · 0.85
Edge_GetDestNodeIDFunction · 0.85

Tested by

no test coverage detected