| 327 | } |
| 328 | |
| 329 | static 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 | |
| 359 | static void addIncomingNeighbors |
| 360 | ( |
no test coverage detected