Elastic optical networks flexibly allocate bandwidth to a connection for improving utilization efficiency. The paper considers an optical node architecture that is similar to a three-stage Clos network for elastic optical networks. The architecture, which employs space switching in the first and the third stages and wavelength switching in the second stage, is called an S-W-S switching fabric. In this paper, we propose a graph-theoretic approach and different routing algorithms to derive the sufficient conditions under which an S-W-S switching fabric will be rearrangeable nonblocking and repackable nonblocking. The proposed rearrangeable and repackable nonblocking S-W-S switching fabrics for connections with limited bandwidths consume around half the number of middle wavelength switches compared to strictly nonblocking S-W-S switching fabrics.