Matching element of arrays on a condition
They key here is to to be able to abstract common functionality away. You're not expressing "node[i] is in the neighbor array" nicely. Simply write a function which does it for you:

int node_in_neighbors(int node, int neighbor[], int length) {
    int i;

    for(i = 0; i &lt; length; i++) {
        if (neighbor[i] == node) { 
            return 1;              
        }
    }
    return 0;
}


In a more "high-level" language, you wouldn't have to write this function, and it would be in the library. You can now rewrite your forward/backward loops easily:

// to find in forward direction
for (i = 0; i &lt; 4; i++) {
    // keep a node if his successor and him are in the neighbors array
    if (node_in_neighbors(node[i], neighbor, 4)
            &amp;&amp; node_in_neighbors(node[i+1], neighbor, 4)) {
        found_indices[fwd_count ++] = node[i]; 
    }
}                                                                      

// to find in backward direction
for (i = 4; i &gt; 0; i--) {
    // keep a node if his predecessor and him are in the neighbors array
    if (node_in_neighbors(node[i], neighbor, 4)
            &amp;&amp; node_in_neighbors(node[i-1], neighbor, 4)) {
        found_indices[count ++] = node[i];
    }
}


This makes the code clearer, since it's way easier to understand the logic now.

One issue is that you still have lots of 4 around. You should replace those in the loop with node_length - 1 and those in the node_in_neighbors call by neighbor_length, otherwise you could confuse them.

Define those lengths like this:

int node_length = sizeof(node) / sizeof(node[0])
int neighbor_length = sizeof(neighbor) / sizeof(neighbor[0])


This trick only works on static arrays, be careful.