Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. path(Start, Dest, [[Start,Dest]]) :- connected(Start, Dest).
  2. path(Start, Dest, [[Start, Waypoint]|Path]) :- dif(Dest, Waypoint),
  3. connected(Start, Waypoint), path(Waypoint, Dest, Path).
  4.  
  5. alldifferent(_,[]).
  6. alldifferent(X,[L|Ls]) :- dif(X,L), alldifferent(X,Ls).
  7.  
  8. pathaux(Start, Dest, [Start,Dest],Q) :- connected(Start, Dest), alldifferent(Start,Q).
  9. pathaux(Start, Dest, [Start, Waypoint|Path],Q) :- dif(Dest, Waypoint),
  10. connected(Start, Waypoint),
  11. pathaux(Waypoint, Dest, Path, [Start|Q]), alldifferent(Start,Q).
  12.  
  13. path(X,Y,Z) :- pathaux(X,Y,Z,[]).
  14.  
  15. connected(ataba,naguib).
  16. connected(naguib,sadat).
  17. connected(sadat,opera).
  18. connected(opera,dokki).
  19. connected(opera,ataba). //Note this one
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement