【发布时间】:2012-05-29 10:58:41
【问题描述】:
在 Prolog 中,如何实现图算法以找到所有路径以在有向图中实现旅行商问题?
例子:
graph
expected input expected output X -----> Y
start X X Y X Z Y -----> T
end Z Y T X Y Z T -----> Z
T Z X Y T Z Y -----> Z
Y Z X -----> Z
X Z
如您所知,在有向图中,可能存在一个循环。但是,不需要两次通过同一点。
graph expected output
X ----> Y
Y ----> X X Y Z
Y ----> Z
我之所以取消这个案例是因为;
output :
X Y X Y ... Z
^^^
god knows this length ( when program terminates )
termination is np problem
【问题讨论】:
标签: prolog graph-theory