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

Function addOutgoingNeighbors

src/procedures/proc_ss_paths.c:324–352  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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