I believe that this problem is NP-complicated due to the reduction from the non-oriented problem of the long path, which is known to be NP-difficult due to the reduction from the problem of the non-oriented Hamiltonian path (see Sipser's Introduction to Computational Theory for more information on why).
In the problem of an undirected long path, we introduce as an undirected graph G = (V, E) together with a pair of nodes u and v and some number k and we want to determine whether or not a simple (no node appears twice) path from u to v of length not less than k. We can transform this into your problem using the polynomial-time reduction as follows:
- For each node v i & in; V, there is a device in (call it d i ).
- For each edge {v i , v j } & in; V, there is a device in B (call it e i, j ).
- For each node v i and edge {v i , v j }, device d i is compatible with device e i, j .
This reduction has a polynomial size, since the total number of generated devices has a size | V | + | E | and the number of connections is 2 | E |. Moreover, we can see that there exists a path of length k from v i to v j in column G if there is a chain of devices 2k + 1 in length from d i to d j . In particular, if ((v i 1 , v i 2 ), (v i 2 , v i 3 ), ..., (v i k - 1 , v i k )) this is a simple way from v i to v j , then the chain d i 1 โ e i 1 , i 2 โ d i 2 โ e i 2 , i 3 โ d i 3 โ ... โ e i k - 1 , i k โ d i k and vice versa. Thus, we have a reduction in polynomial time from the non-oriented longest path to your problem as follows:
- It is indicated as an input (G, v i , v j , k) to the problem of an omnidirectional long path:
- Build sets A and B, as described above, with C compatibility, as described above.
- Check if there is a chain of devices 2k + 1 in length from d i to d j .
- If so, print "yes"
- If not, print "no."
This reduction solves the problem of the non-directional long path in non-deterministic polynomial time using a solver for your problem, so your problem is NP-hard. As a result, you should not expect to find a polynomial-time algorithm for your problem; finding the exact answer is likely to take an exponential time, if only P = NP.
Sorry to give a negative answer, but I hope this helps!
source share