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