Localization is an essential service for many wireless sensor network applications. While several localization schemes rely on anchor nodes and range measurements to achieve fine-grained positioning, we propose a range-free, anchor-free solution that works using connectivity information only. The approach, suitable for deployments with strict cost constraints, is based on the neural network paradigm of Self-Organizing Maps (SOM). We present a lightweight SOM-based algorithm to compute virtual coordinates that are effective for location-aided routing. This algorithm can also exploit the location information, if available, of few anchor nodes to compute absolute positions. Results of extensive simulations show improvements over the popular Multi-Dimensional Scaling (MDS) scheme, especially for networks with low connectivity, which are intrinsically harder to localize, and in presence of irregular radio pattern or anisotropic deployment. We analytically demonstrate that the proposed scheme has low computation and communication overheads; hence, making it suitable for resource-constrained networks.