%%%%%%%%%%%%%%%%%%%%%%%%%
%                       %
% Shorted Path in graph %
%                       %
%%%%%%%%%%%%%%%%%%%%%%%%%

:- set_prolog_flag(toplevel_print_options,
                   [quoted(true), portray(true), max_depth(0)]).

:- use_module(astar).



shortest(Start, Path) :-
    solve(Start, Path2),
    reverse(Path2, Path).

solve(A, B) :-
    bestfirst(A, B).


s(s, e, 2).
s(e, s, 2).
s(e, f, 5).
s(f, e, 5).
s(f, g, 2).
s(g, f, 2).
s(g, t, 2).
s(t, g, 2).
s(t, d, 3).
s(d, t, 3).
s(d, c, 3).
s(c, d, 3).
s(c, b, 2).
s(b, c, 2).
s(b, a, 2).
s(a, b, 2).
s(a, s, 2).
s(s, a, 2).


h(s, 6).
h(a, 5).
h(b, 4).
h(c, 4).
h(d, 3).
h(t, 0).
h(g, 2).
h(f, 4).
h(e, 7).


goal(X) :- X = t.  % t is the goal node

