众所周知,计算具有最小可能叶数的生成树是NP完成的。但我无法弄清楚这个问题的多项式时间减少到哈密顿路径问题。
我的指数减少:
if(hamiltonian path exists for whole graph)
min leaves = 1;
return;
else
for each vertex of the graph
if(hamiltonian path exists for this graph after removing the vertex and its incident edges)
min leaves = 2;
return;
continue similarly for the graph deleting 2 vertices, 3 vertices, 4vertices,... until you get a minimum spanning tree with some minimum number of leaves.
所以,在最坏的情况下,这个算法将总计
(N choose 1) + (N choose 2) + (N choose 3) + ....(N choose N) = 2^N
调用哈密顿路径问题。因此减少是指数级的。
请为此问题建议多项式时间减少。
答案 0 :(得分:2)
减少算法的想法是,如果你能证明哈密顿路径问题可以用约束的MST问题解决(用多项式时间减少),那么MST问题的任何多项式时间解决方案都可以让你求解多项式时间的哈密顿路径问题。由于这是不可能的,它将证明受约束的MST问题不能在多项式时间内得到解决。
你要做的事情恰恰相反 - 证明汉密尔顿路径问题至少与受约束的MST问题一样困难。
请注意,您在评论中指出,您的任务是减少来自哈密尔顿路径问题,而在您提出的问题中,您试图将减少为哈密顿量路径问题。
您可以使用约束MST问题轻松解决哈密顿路径问题,因为哈密顿路径将始终是具有2(或哈密顿循环0)叶子的生成树。