为什么 `depthfirst2` 总是被标记为红色?

Why `depthfirst2` is always marked as red?

得到了下面的深度搜索程序,但是depthsearch谓词总是被标记为红色,所以我无法运行这个程序。有什么问题?

node(a).
node(b).
node(c).
node(d).
node(e).
node(f).
node(g).
node(h).
node(i).
node(j).

s(a,b). s(a,c).
s(b,d). s(b,e).
s(c,f). s(c,g).
s(d,h).
s(e,i). s(e,j).
goal(j).
goal(f).

depthfirst2( Node, [Node], _) :-
    goal( Node).

depthfirst2( Node, [Node | Sol], Maxdepth) :-
    Maxdepth > 0,
    s( Node, Node1),
    Max1 is Maxdepth - 1,
    depthfirst2( Node1, Sol, Max1).

您的代码运行正常。 尝试将谓词称为:

?-depthfirst2(a,L,4).

OUTPUT:
L = [a, b, e, j]
L = [a, c, f]
false