-


- - . 22


predicates
path(s,s,list,i)
path1(s,list,i,list,i)
member(s,list)
arca(s,s,i)
db0(s,s)
db(s,s)
clauses
arca(a,b,1). arca(b,c,3). arca(c,d,1). arca(b,d,7). arca(a,d,1).
member(X,[X|_]).
member(X,[_|Tail]):- member(X,Tail).
path(A,Z,Path,C):- path1(A,[Z],0,Path,C).
path1(A,[A|Path1],C,[A|Path1],C).
path1(A,[Y|Path1],C1,Path,C):- arca(X,Y,CXY), not(member(X,Path1)),
C2=C1+CXY, path1(A,[X,Y|Path1],C2,Path,C).
/* X Y */
db0(X,Y) :-path(X,Y,P,C),
assert(db_path(X,Y,P,C)).
db(X,Y):-db_path(X,Y,P,C),
path(X,Y,MP,MC),
MC<C,!,
retract(db_path(X,Y,P,C)),
assert(db_path(X,Y,MP,MC)),
db(X,Y).
db(_,_).
goal
/* MP MC a
b */
db0(a,d), db(a,d), db_path(a,d,MP,MC), write("\nMP=",MP,"\nMC=",MC).
5.2.2.
,
. G=(V,E) -
T=(V,E1) , E1 - E.

osttree(e,T),
T - G (G - ),e -
G.
:
1) G; 2) , , ;
3) , , , . : , , .
, ,



- -  - -  - -