Graph Clingo中图形的意外结果
我正在尝试用Clingo编写一个程序来求解Euler路径。到目前为止,这就是我所想到的。我希望我的图表显示如下。 我的意见Graph Clingo中图形的意外结果,graph,answer-set-programming,Graph,Answer Set Programming,我正在尝试用Clingo编写一个程序来求解Euler路径。到目前为止,这就是我所想到的。我希望我的图表显示如下。 我的意见 edge(a,b). edge(b,c). edge(c,d). edge(d,e). edge(a,d). edge(b,d). %edge(x,y):-edge(y,x). num(1..6). 我的计划到目前为止 %Generates paths with X and Ys equal to e
edge(a,b).
edge(b,c).
edge(c,d).
edge(d,e).
edge(a,d).
edge(b,d).
%edge(x,y):-edge(y,x).
num(1..6).
我的计划到目前为止
%Generates paths with X and Ys equal to edges in the input, N can be in the range of 'num'
1{path(X,Y,N):edge(X,Y)}1:-num(N).
%Next edges Y and X1 are the same/connect. Where N is in the range of indices.
:-path(X,Y,N), path(X1,Y1,N+1), Y!=X1, num(N).
我在程序中的评论是否不正确?
我认为程序应该是,它应该总是将边连接在一起。
现在我没有得到答案,但是当步骤数“num”在1到4之间时,我得到了一个解决方案。我认为Euler路径应该有6个步骤,但可能的解决方案是:
path(b,d,1)
path(d,a,2)
path(a,b,3)
path(b,c,4)
path(c,d,5)
path(d,e,6)
明白了
这是输入文件
edge(a,b).
edge(b,c).
edge(c,d).
edge(d,e).
edge(a,d).
edge(b,d).
edge(X,Y):-edge(Y,X).
num(1..6).
和输出文件
1{path(X,Y,N):edge(X,Y)}1:-num(N).
%Next edges Y and X1 are the same/connect. Where N is in the range of indices.
:-path(X,Y,N), path(X1,Y1,N+1), Y!=X1, num(N).
%Accept no duplicate paths
:-path(X,Y,N), path(X1,Y1,N2), Y==Y1, X==X1, num(N), num(N2), N!=N2.
:-path(X,Y,N), path(X1,Y1,N2), Y==X1, X==Y1, num(N), num(N2), N!=N2.
#hide.
#show path/3.
在我的机器上产生如下输出(为了可读性而反转):
明白了
这是输入文件
edge(a,b).
edge(b,c).
edge(c,d).
edge(d,e).
edge(a,d).
edge(b,d).
edge(X,Y):-edge(Y,X).
num(1..6).
和输出文件
1{path(X,Y,N):edge(X,Y)}1:-num(N).
%Next edges Y and X1 are the same/connect. Where N is in the range of indices.
:-path(X,Y,N), path(X1,Y1,N+1), Y!=X1, num(N).
%Accept no duplicate paths
:-path(X,Y,N), path(X1,Y1,N2), Y==Y1, X==X1, num(N), num(N2), N!=N2.
:-path(X,Y,N), path(X1,Y1,N2), Y==X1, X==Y1, num(N), num(N2), N!=N2.
#hide.
#show path/3.
在我的机器上产生如下输出(为了可读性而反转):