I have an unweighted undirected graph and I have to find if there exists a path between two vertices $u,v$ that visits set of specific nodes $A$. $A$ can contain $1-10$ nodes. No node can be visited more than once.
I thought about finding all paths between $u,v$ and then check if those paths contain vertices from $A$. I optimized it by not considering those paths in which no of vertices is less than cardinality of $A$. But this doesn't affect much. If $A$ has only one then it's useless.
As suggested in comments, I want to start with 1 node in $A$ to simplify it. I will try to extend it to multiple vertices on my own.
There's another way if we precalculate path between every pair of nodes and then check if we have a path passing through $A$ but the time complexity will be very costly.
I was thinking if it can be done using lower bounds max-flow : The lower bound max-flow algorithm computes a flow, which must include all the edges that have a positive $(>0)$ lower bound value. If only one edge has a positive lower bound, the flow computed by the algorithm can be used to build a simple path, which includes such edge. The “edge” instance of the problem can be transformed into its “node” equivalent by first splitting the include-node into two half-nodes, i.e., $n_1$ and $n_2$. All incoming edges to the original node converge to $n_1$. All outgoing edges of the original node emerge from $n_2$. A directed edge $e_l$ from $n_1$ to $n_2$ is added with a positive lower bound value. All other (original) edges of the network have zero lower bound. Now, applying the lower bound max-flow algorithm to this flow network, a feasible flow from source to destination can be found such that $e_l$ is included in at least one of the (flow) augmenting paths.
Then on merging $n_1$and $n_2$ the simple path can be traced. But I couldn't think of code or that matter a code to implement it.
EDIT: The problem here lies about how to make it a simple path so as to not to repeat vertices.
So is there any an efficient way to do this (maybe polynomial or less)?