How to determine the optimal communication path in wireless sensor networks (WSNs) is a fundamental problem. In this letter, we formulate the optimal communication path problem and convert it into the shortest path tree (SPT) problem by considering an external base station and sensors as the root node and leaf nodes, respectively. Inspired by a path-finding mathematical model Physarum solver, a novel bio-inspired algorithm is proposed to solve the SPT problem in WSNs. Experimental results demonstrate that the proposed algorithm also has an advantage of adaptivity and performs better than Physarum solver in dynamic small WSNs.Index Terms-Physarum solver, slime mold, wireless sensor network, shortest path tree, optimization.