问题
[
]How can I write (using print_path
) a rule to print the path from one node to another if exists
Print_path(a, c, Res) ---> Res=[a, f, c]
What I did was :
path(a,b). %there is a path from a to b
path(a,f).
path(b,c).
path(c,d).
path(c,e).
path(e,d).
path(f,g).
path(f,c).
path(f,e).`
I do not know what to do next.
来源:https://stackoverflow.com/questions/41112132/find-the-shortest-path-between-two-nodes-in-a-graph-in-prolog-and-display-the