The aim of this study is to provide a mathematical framework for studying node cooperation, and to define strategies leading to optimal node behaviour in ad hoc networks. In this study we show time performances of three different methods, namely, Dijkstra's algorithm, Dijkstra's algorithm with battery times and cooperative flow game algorithm constructed from a flow network model. There are two main outcomes of this study regarding the shortest path problem which is that of finding a path of minimum length between two distinct vertices in a network. The first one finds out which method gives better results in terms of time while finding the shortest path, the second one considers the battery life of wireless devices on the network to determine the remaining nodes on the network. Further, optimization performances of the methods are examined in finding the shortest path problem. The study shows that the battery times play an important role in network routing and more devices provided to keep the network. To view the time performance analysis of the methods MATLAB is used. Also, considering the cooperation between the nodes, it is envisaged that using cooperative game theory brings a new approach to network traffic engineering and routing methods.