algorithm - How to find the longest simple path in a graph? -


I know that this problem is np-full for a non-guided graph so that we can check the browser Should do the path how can we do it? Please suggest a pseudo-code and tell me the complexity of that algorithm.

If it is customizable, then it will be great!

A simple approach can run through all possible top permutations.

For every permutation, {v1, ..., vN} you check if you enter v1 to v2 You can get from v2 to v3 and from then on. If you can add, then the length of the length of the corresponding current path, if not, then go to the next permutation.

This is the longest path you have to answer.


Or, you can do a lot by using recycling.

Path = 0 Best Peth = 0 used = New Bull [N] / / (U = 0; U & lt; N; U ++) Falls for Path (U) Start with; // The best page of paths starting with URI print

Where

  Path (U) in the neighborhood (u) = real foreach v Used (=) (V) path - = distance (U, V) used [u] = false  
used [V]) path + = distance (U, V) bestPath = max (Best Path, Path)

The complexity of time is terrible O (N * N ^ N) .


Comments