Let XX be a topological space. A separation of XX is a pair of disjoint non-empty open sets whose union is X.X. XX is disconnected if it has a separation and connected otherwise, and a subset A⊆XA\subseteq X is connected if it is connected as a subspace. Equivalently, XX is connected if and only if the only subsets of XX that are both open and closed are ∅\varnothing and X.X.

A subset of R\mathbb{R} is connected if and only if it is an interval. The rational numbers are disconnected, since {x∈Q:x<2}\left\{x\in\mathbb{Q}:x<\sqrt{2}\right\} and {x∈Q:x>2}\left\{x\in\mathbb{Q}:x>\sqrt{2}\right\} separate them, and a set with the discrete topology is connected only if it has at most one point. Connected sets have the following properties:

  • the closure of a connected set is connected, as is any set between a connected set and its closure;
  • the union of connected sets with a common point is connected;
  • the product of finitely many connected spaces is connected;
  • the continuous image of a connected set is connected.

The last property states that if f:X→Yf:X\rightarrow Y is continuous and A⊆XA\subseteq X is connected then f(A)f(A) is connected. Since the connected subsets of R\mathbb{R} are the intervals, a continuous real-valued function on a connected space takes every value between any two of its values, which extends the intermediate value theorem. Connectedness is a topological property, so an interval is not homeomorphic to a circle, which stays connected when a point is removed.

Let x∈X.x\in X. The connected component of xx is the union of all connected subsets of XX containing x,x, which is the largest connected set containing x.x. The connected components partition XX into closed sets, and XX is connected if and only if it has exactly one component. The components of Q\mathbb{Q} are its single points.

A path in XX from xx to yy is a continuous function γ:[0,1]→X\gamma:\left[0,1\right]\rightarrow X with γ(0)=x\gamma(0)=x and γ(1)=y.\gamma(1)=y. XX is path-connected if any two of its points are joined by a path, and the path component of xx is the set of points joined to xx by a path. A subset of Rn\mathbb{R}^n that contains the line segment {(1−t)x‾+t y‾:t∈[0,1]}\left\{\left(1-t\right)\underline{x}+t\,\underline{y}:t\in\left[0,1\right]\right\} between any two of its points is path-connected by those segments, so balls, intervals and Rn\mathbb{R}^n are path-connected, as are spheres and Rn\mathbb{R}^n with a point removed when n≥2.n\geq 2. The continuous image of a path-connected set is path-connected.

A path-connected space is connected, since the image of each path is connected and the paths from a fixed point share that point. The converse is false: the topologist’s sine curve, the closure in R2\mathbb{R}^2 of the graph of x↦sin⁡1xx\mapsto\sin\frac{1}{x} on (0,1],\left(0,1\right], is connected but no path joins the graph to the segment {0}×[−1,1]\left\{0\right\}\times\left[-1,1\right] in its closure. An open connected subset of Rn\mathbb{R}^n is path-connected, and any two of its points are joined by a path made of finitely many line segments, so the two notions agree for the open sets on which vector fields are defined.