If E
is the number of edges and V
is the number of vertices, this greedy algorithm runs in O(E * V)
.
Therefore, the time growth is quadratic when E
and V
increase. There is no dead loop.
In addition, the memory space needed also increases and may force your computer to swap thus increasing dramatically the overall time.