Suppose I have an undirected graph $G=(V,E)$, and boolean variables $x_v$ (one for each vertex $v \in V$). These variables select a subset $S \subseteq V$ of vertices, namely the vertices $S=\{v \mid x_v\}$ whose corresponding boolean variable is true.
I want to express the constraint that $S$ is connected, i.e., that the vertices selected by the $x_v$'s form a connected component in $G$. How can I do that, in a way that can be used with a SAT solver or ILP solver?
Equivalently, this can be viewed as enforcing the constraint that all of the vertices in $S$ are reachable from each other, so this can be viewed as how to encode reachability constraints in SAT.