A routing algorithm for wireless sensor networks with a random distribution in a target observation area is proposed. In practice, selecting a path to route data from a source node to a destination node in a sensor network is very useful. An investigation is carried out on the combination of centrality measures and a routing algorithm to determine whether this can improve the route selected by the network’s decision. Various measures of centrality are used and the network’s response is evaluated with regards to the route selected by the network’s decision when some nodes fail. It is demonstrated through simulations that controlling sensor nodes efficiently with a high measure of centrality gives a network the ability to resist node failures or attacks. Furthermore, this provides the network with high failure tolerance. In this paper, a routing algorithm that uses centrality measures to select the shortest path (a low-energy path between the source and destination node) is implemented.