简体   繁体   中英

Is the problem of finding the simple path with maximum cost in a weighted undirected graph with the same number of vertex and edges NP-Complete?

Hello and thanks again for reading this.

I need to know now if the problem of finding the simple path with maximum cost in a weighted undirected graph with the same number of vertex and edges is NP-Complete or not?

Input: Graph G = (V,E) with V (vertex) = E (edges)

Output: The cost of the most expensive path in the graph G.

Could you provide any reference to an article where I can review this.

Thank you very much for your time.

Sincerely,

Alex.

This problem is called the Longest Path Problem , and is NP-complete.

The restriction |V| = |E| |V| = |E| doesn't help at all. You can solve an arbitrary graph by adding unconnected vertices until you satisfy the relation.

If the graph is not necessarily connected, then any instance of the longest path problem can be reduced to this problem by adding extra isolated vertices to the input graph to make the number of nodes and edges the same. If this isn't thyroid case, and the graph must be connected, then the input graph must have exactly one cycle, since a graph with n-1 edges is a tree. IF you find this cycle with a DFS and contract it to a single node, you then have a tree. It's easy to do longest path computations here; just consider all pairs of edges and get the cost of the unique path between them. If you take this path ans then expand it in the original graph by walking around the cycle where you originally went through the contracted node, I think you get the longest path in polynomial time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM