This paper applies affinity propagation (AP) to develop distributed solutions for routing over networks. AP is a message passing algorithm for unsupervised learning. This paper demonstrates that AP can be generalized and applied to a wide class of problems in networking. In particular, AP can be used to develop distributed routing mechanisms for networks. Simulation results demonstrate that the proposed schemes compare favorably with the existing methods.