[step:Join overlapping connected subsets to prove transitivity]Let $x,y,z \in X$ and assume $x \sim y$ and $y \sim z$. By definition of $\sim$, there are connected subsets $A,B \subset X$ such that $x,y \in A$ and $y,z \in B$. Since $y \in A \cap B$, the intersection $A \cap B$ is nonempty.
[claim:The union of two connected subsets with nonempty intersection is connected]
Let $A,B \subset X$ be connected subsets in the subspace topology, and suppose $A \cap B \neq \varnothing$. Then $A \cup B$ is connected in the subspace topology.
[/claim]
[proof]
Suppose, toward a contradiction, that $A \cup B$ is disconnected. Then there exist disjoint nonempty subsets $U,V \subset A \cup B$ that are open in the subspace topology on $A \cup B$ and satisfy
\begin{align*}
A \cup B = U \cup V.
\end{align*}
The sets $U \cap A$ and $V \cap A$ are open in the subspace topology on $A$, disjoint, and their union is $A$. Since $A$ is connected, one of them is empty. Hence $A \subset U$ or $A \subset V$. The same argument applied to $B$ gives $B \subset U$ or $B \subset V$.
Choose a point $p \in A \cap B$. If $A \subset U$, then $p \in U$, and since $p \in B$, the alternative $B \subset V$ is impossible because $U \cap V = \varnothing$. Thus $B \subset U$. Similarly, if $A \subset V$, then $B \subset V$. Therefore $A \cup B$ is contained entirely in one of $U$ or $V$, contradicting that both $U$ and $V$ are nonempty and cover $A \cup B$. Hence $A \cup B$ is connected.
[/proof]
Applying the claim to the connected subsets $A$ and $B$, we get that $A \cup B$ is connected. Since $x \in A \subset A \cup B$ and $z \in B \subset A \cup B$, there exists a connected subset of $X$ containing both $x$ and $z$. Therefore $x \sim z$, and $\sim$ is transitive.[/step]