Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
path([A], B, Path, 0, Length)
path([B | Rest], B, [B | Rest], Length, Length).
path([A | Rest], B, Path, CurrentLength, Length) :-
oh(A, C, X),
\+member(C, [A | Rest]),
NewLength is CurrentLength + X,
path([C, A | Rest], B, Path, NewLength, Length).
findall(L, some_goal(..., L, ...), List)
findall(L, path([X], Y, Path, 0, L), List)
short_path(X,Y,Len):-findall(Lenght,path([X],Y,Path,0,Lenght),List), Lenght < Len.
minn([H],H).
minn([H|T],Min) :- minn(T,Mum),(H < Mum -> Min = H; Min = Mum).
path(Ori,Dest,Len):-findall(Lenght,route([Ori],Dest,Path,0,Lenght),List),minn(List,M), M < Len,write(Ori),nl,write(Dest).
route([Dest | Rest], Dest, [Dest | Rest], Length, Length).
route([Ori | Rest], Dest, Path, CurrentLength, Length) :-
link(Ori, C,_, X),
\+member(C, [Ori | Rest]),
NewLength is CurrentLength + X,
route([C, Ori | Rest], Dest, Path, NewLength, Length).
findall([Path, Length], route([Ori], Dest, Path, 0, Length), List)
minimum([[Path, Length]], [Path, Length]).
minimum([[Path, Length] | Rest], [Path2, Length2]) :-
minimum(Rest, [Path1, Length1]),
Length < Length1,
Path2 = Path,
Length2 = Length.
minimum([[Path, Length] | Rest], [Path2, Length2]) :-
minimum(Rest, [Path1, Length1]),
Length >= Length1,
Path2 = Path1,
Length2 = Length1.
link(Ori, C,_, X),
link(timisoara,cluj,140,360).
link(timisoara,bucuresti,200,698).
link(timisoara,iasi,110,714).
link(craiova,timisoara,90,370).
link(brasov,craiova,185,399).
link(brasov,bucuresti,190,400).
link(bucuresti,galati,200,285).
link(bucuresti,sibiu,136,403).
link(bucuresti,iasi,195,360).
link(cluj,bucuresti,195,406).
link(cluj,iasi,200,369).
link(cluj,craiova,98,312).
minnn([[Path,Length] | Rest],[Path2,Length2]):-
minnn(Rest,[Path1,Length1]),
Length < Length1,
Path2 = Path,
Length2 = Length.
minnn([[Path,Length] | Rest],[Path2,Length2]):-
minnn(Rest,[Path1,Length1]),
Length >= Length1,
Path2 = Path1,
Length2 = Length1.
short(Ori,Dest,Min):-findall([Path,Lenght],route([Ori],Dest,Path,0,Lenght),List),
minnn(List,Min).
route([Dest | Rest], Dest, [Dest | Rest], Length, Length).
route([Ori | Rest], Dest, Path, CurrentLength, Length) :-
link(Ori, C,_, X),
\+member(C, [Ori | Rest]),
NewLength is CurrentLength + X,
route([C, Ori | Rest], Dest, Path, NewLength, Length).