In this article, we study the application of NetworkX, a Python library for dealing with traffic networks, to the problem of signal optimization at a single intersection. We use the shortest-path algorithms such as Bellman-Ford (Dynamic Programming), A star (A*), and Dijkstra’s algorithm to compute an optimal solution to the problem. We consider both undersaturated and oversaturated traffic conditions. The results show that we find optimal results with short Central Processor Unit (CPU) time using all the applied algorithms, where Dijkstra’s algorithm slightly outperformed others. Moreover, we show that bee colony optimization can find the optimal solution for all tested problems with different degrees of computational complexity for less CPU time, which is a new contribution to knowledge in this field.