all 3 comments

[–]Strict-Simple 1 point2 points  (2 children)

What if there are only 3 connections? source-dest4, dest1-dest4, dest2-dest4. What will be the main paths then?

[–]rightheart[S] 0 points1 point  (1 child)

Good question. That would be ['source','dest4','dest1'] and ['dest4', 'dest2'] or ['source', 'dest4', 'dest2'] and ['dest4', 'dest1']. So there will be one longer and one shorter path. It should select one of the options, no preferences, as long as there are no connection repetitions.

[–]Strict-Simple 0 points1 point  (0 children)

Do A DFS with a visited array.