我正在编写以下代码并且工作正常。
edge(s,a,300,300/500 * 60, 300*1,plane).
edge(s,a,300,300/120 * 60, 300*3/4,train).
edge(s,a,300,300/80 * 60, 300*3/5,bus).
edge(s,a,300,300/100 * 60, 300*2/5,car).
edge(s,a,300,300/5 * 60, 300*0,walk).
edge(s,d,20,20/500 * 60, 20*1,plane).
edge(s,d,20,20/120 * 60, 20*3/4,train).
edge(s,d,20,20/80 * 60, 20*3/5,bus).
edge(s,d,20,20/100 * 60, 20*2/5,car).
edge(s,d,20,20/5 * 60, 20*0,walk).
edge(a,d,400,400/500 * 60, 400*1,plane).
edge(a,d,400,400/120 * 60, 400*3/4,train).
edge(a,d,400,400/80 * 60, 400*3/5,bus).
edge(a,d,400,400/100 * 60, 400*2/5,car).
edge(a,d,400,400/5 * 60, 400*0,walk).
edge(a,b,1500,1500/500 * 60, 1500*1, plane).
edge(a,b,1500,1500/120 * 60, 1500*3/4,train).
edge(a,b,1500,1500/80 * 60, 1500*3/5,bus).
edge(a,b,1500,1500/100 * 60,1500*2/5, car).
edge(a,b,1500,1500/5 * 60, 1500*0,walk).
edge(b,c,9,9/500 * 60, 9*1,plane).
edge(b,c,9,9/120 * 60, 9*3/4,train).
edge(b,c,9,9/80 * 60, 9*3/5,bus).
edge(b,c,9,9/100 * 60,9*2/5, car).
edge(b,c,9,9/5 * 60, 9*0,walk).
edge(b,e,200,200/500 * 60, 200*1, plane).
edge(b,e,200,200/120 * 60, 200*3/4,train).
edge(b,e,200,200/80 * 60, 200*3/5,bus).
edge(b,e,200,200/100 * 60, 200*2/5,car).
edge(b,e,200,200/5 * 60, 200*0,walk).
edge(c,d,2000,2000/500 * 60, 2000 * 1,plane).
edge(c,d,2000,2000/120 * 60, 2000 * 3/4,train).
edge(c,d,2000,2000/80 * 60, 2000 * 3/5,bus).
edge(c,d,2000,2000/100 * 60, 2000 * 2/5,car).
edge(c,d,2000,2000/5 * 60, 2000 * 0,walk).
edge(c,g,12,12/500 * 60, 12 * 1,plane).
edge(c,g,12,12/120 * 60, 12 * 3/4,train).
edge(c,g,12,12/80 * 60, 12 * 3/5,bus).
edge(c,g,12,12/100 * 60, 12 * 2/5,car).
edge(c,g,12,12/5 * 60, 12 *0 ,walk).
edge(d,e,3,3/500 * 60, 3* 1,plane).
edge(d,e,3,3/120 * 60, 3 * 3/4,train).
edge(d,e,3,3/80 * 60, 3 * 3/5,bus).
edge(d,e,3,3/100 * 60, 3 * 2/5,car).
edge(d,e,3,3/5 * 60, 3 * 0,walk).
edge(e,f,400,400/500 * 60, 400 * 1,plane).
edge(e,f,400,400/120 * 60, 400 * 3/4,train).
edge(e,f,400,400/80 * 60, 400 * 3/5,bus).
edge(e,f,400,400/100 * 60, 400 * 2/5,car).
edge(e,f,400,400/5 * 60, 400 * 0,walk).
edge(f,g,800,800/500 * 60, 800 * 1,plane).
edge(f,g,800,800/120 * 60, 800 * 3/4,train).
edge(f,g,800,800/80 * 60, 800 * 3/5,bus).
edge(f,g,800,800/100 * 60, 800 * 2/5,car).
edge(f,g,800,800/5 * 60, 800 * 0,walk).
connected(X,Y,D,T,C) :- edge(X,Y,D,T,C,M) ; edge(Y,X,D,T,C,M).
path(A,B,D,T,C,Path) :-
travel(A,B,D,T,C,[A],Q),
reverse(Q,Path).
travel(A,B,D,T,C,P,[B|P]) :-
connected(A,B,D,T,C).
travel(A,B,D,T,C,Visited,Path) :-
connected(A,X,D1,T1,C1),
X \== B,
\+member(X,Visited),
travel(X,B,D2,T2,C2,[X|Visited],Path),
D is D1 + D2,
T is T1 + T2,
C is C1 + C2.
我想知道所选路径的运输方式。
我无法将其添加到列表中。
所以,如果我像这样查询
| ? - path(s,e,D,T,C,P,M), T<3.
给我一个对应于描述运输方式的每条路径的列表