| 90 | } |
| 91 | |
| 92 | void addIncomingNeighbors |
| 93 | ( |
| 94 | AllPathsCtx *ctx, |
| 95 | LevelConnection *frontier, |
| 96 | uint32_t depth |
| 97 | ) { |
| 98 | EntityID frontierId = INVALID_ENTITY_ID; |
| 99 | if(depth > 1) frontierId = ENTITY_GET_ID(&frontier->edge); |
| 100 | |
| 101 | // Get frontier neighbors. |
| 102 | for(int i = 0; i < ctx->relationCount; i++) { |
| 103 | Graph_GetNodeEdges(ctx->g, &frontier->node, GRAPH_EDGE_DIR_INCOMING, ctx->relationIDs[i], &ctx->neighbors); |
| 104 | } |
| 105 | |
| 106 | // Add unvisited neighbors to next level. |
| 107 | uint32_t neighborsCount = array_len(ctx->neighbors); |
| 108 | |
| 109 | //-------------------------------------------------------------------------- |
| 110 | // apply filter to edge |
| 111 | //-------------------------------------------------------------------------- |
| 112 | if(ctx->ft) { |
| 113 | for(uint32_t i = 0; i < neighborsCount; i++) { |
| 114 | Edge e = ctx->neighbors[i]; |
| 115 | |
| 116 | // update the record with the current edge |
| 117 | Record_AddEdge(ctx->r, ctx->edge_idx, e); |
| 118 | |
| 119 | // drop edge if it doesn't passes filter |
| 120 | if(FilterTree_applyFilters(ctx->ft, ctx->r) != FILTER_PASS) { |
| 121 | array_del_fast(ctx->neighbors, i); |
| 122 | i--; |
| 123 | neighborsCount--; |
| 124 | } |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | _AllPathsCtx_EnsureLevelArrayCap(ctx, depth, neighborsCount); |
| 129 | for(uint32_t i = 0; i < neighborsCount; i++) { |
| 130 | // Don't follow the frontier edge again. |
| 131 | if(frontierId == ENTITY_GET_ID(ctx->neighbors + i)) continue; |
| 132 | // Set the neighbor by following the edge in the correct directoin. |
| 133 | Node neighbor = GE_NEW_NODE(); |
| 134 | Graph_GetNode(ctx->g, Edge_GetSrcNodeID(ctx->neighbors + i), &neighbor); |
| 135 | // Add the node and edge to the frontier. |
| 136 | _AllPathsCtx_AddConnectionToLevel(ctx, depth, &neighbor, (ctx->neighbors + i)); |
| 137 | } |
| 138 | array_clear(ctx->neighbors); |
| 139 | } |
| 140 | |
| 141 | // Traverse from the frontier node in the specified direction and add all encountered nodes and edges. |
| 142 | void addNeighbors |
no test coverage detected