Hi,

for a graph that has N nodes (with N<=10^4) is an O(n^2) complexity acceptable or it is possible to have a lower complexity?

Depth First Search is in O(n log(n)) but when I apply it for N nodes the total complexity becomes O(n^2 log(n)).

What should I do to better optimize my code?

Thank you