Find the shortest path between two nodes in a grap

2019-09-19 07:06发布

问题:

[]

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.