Networks are everywhere and their applications in various fields such as computer science, biological science, economics, and chemical engineering attracted attention of many researchers. Many complex systems in the real world can be represented by networks or graphs. Link prediction is one of the most important tasks in network analysis, thus attracting tremendous research interests in the last decades. In this paper, we present a novel algorithm for link prediction that works efficiently for both unipartite graphs and bipartite graphs. Our novel algorithm is based on the concept of eigenvectors and shortest distance between the nodes. We used the Peron–Frobenius theorem of node importance for link prediction. Four metrics, namely AUC, precision, prediction-power, and precision@K, were computed and compared with fourteen baseline algorithms to test the performance of the proposed algorithm. Testing was done on the thirteen datasets, and experimental results show that the proposed method outperforms the baseline algorithm on the basis of four given metrics. © 2021, The Author(s), under exclusive licence to Springer-Verlag GmbH Austria, part of Springer Nature.