开发者

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?

开发者 https://www.devze.com 2023-02-01 22:05 出处:网络
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-C

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)

开发者_如何学JAVA

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.


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.


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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号