this is a follow up on this question:
Where Robert in fact provided me a nice idea to check if the solution has the two nodes connected.
In fact I'd like my problem to be actually constrained to select only solutions that have those two vertices connected, so I tought that adding the followin constraints would work:
let $y_a$ and $y_b$ be binary variables representing the two nodes to be connected, and $y_i,y_j,...$ binary variables associated to two generics nodes. maximize the sum:
$\sum_i y_i$ subject to:
$y_i=(a_ij)yj+a_ij(y_i)$ %% this is the if-then statement
$y_a=0$ %%the source node is set to 0
$y_b=0$ %%this was my idea to force that the destination is connected, but in fact it doesn't work
the problem is that imposing yb=0 does not imply that ya and yb are in fact connected as I tought before writing it up, since two separate graphs that are not connected would be a feasible solution.
What could I do to force this type of constraint?
Edit: an idea seems to be considering the problem of maximum flow, I'll update this question if I manage to find a working solution since I saw multiple other questions around the internet with no answers.