There are n segments on the two-dimensional plane. The two endpoints of ith segment is ($S_{x_i}$, $S_{y_i}$) and ($T_{x_i}$, $T_{y_i}$). All the segments are parallel to the x-axis or y-axis. These segments actually form a undirected graph with infinite nodes and edges.
We want to know whether these segments form a tree, which means: for every pair of different points on these segments, they are connected by exactly one simple path.
(In our segment-based undirected graph, a “path” is considered as a continuous infinite set of points in these segments, a “simple path” is a path that each point in the set appears only once, and two simple paths are considered to be different if and only if their corresponding point sets are different. )