bhai, dynamic prog. can solve every type of problem on this earth which is possible via code apart from the prob. where we apply machine learning algo. it is just the time boundation and efficiency that decdide which one we will pick.

I have implemented using DFS for a graph ( may contain cycles or not ).

I checked for the following graph:

Now, it gave wrong max diameter for vertex 2 . It was supposd to have 1-3, 2-3, 2-4 edges but included 2-3, 1-3, 3-4 edges instead and counted max diameter as 2.

But, vertices 4 and 1 should have same set of edges for considering max diameter viz. 1-3, 2-3, 2-4 and it considered that correctly.

So, I think that if there more than 1 vertces having the same set of edges for max diameter, then it may give wrong max diameter fr one of them but correct for one or allof others.