I have a general question regarding how to find shortest path and longest path in an undirected graph with simple edges where edges have no weights.
Is it a correct conclusion that we need to use DFS algorithm to find the longest path in a graph, while we need to use BFS algorithm to find shortest path in a graph.
I understand that when we use BFS we visit the nodes layer by layer, and we can use it for shortest path finding (that is probably why Dijkstra is BFS-based or similar to BFS). But i do not see how efficiently we can find the longest path from using BFS. Can somebody elaborate?
Also, I understand that using DFS to find the longest path might not efficient and we may need to use Dynamic programming idea to enhance the time complexity, but lets ignore it for the sake of functionality for this discussion.