⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fig9_21.pl

📁 超多的prolog源代码 具体内容见压缩包里面的programs.txt
💻 PL
字号:
% Figure 9.21   Path-finding in a graph:  Path is 
% an acyclic path with cost Cost from A to Z in Graph.


% path( A, Z, Graph, Path, Cost):
%    Path is an acyclic path with cost Cost from A to Z in Graph

path( A, Z, Graph, Path, Cost)  :-
  path1( A, [Z], 0, Graph, Path, Cost).

path1( A, [A | Path1], Cost1, Graph, [A | Path1], Cost1).

path1( A, [Y | Path1], Cost1, Graph, Path, Cost)  :-
   adjacent( X, Y, CostXY, Graph),
   not member( X, Path1),
   Cost2 is Cost1 + CostXY,
   path1( A, [X, Y | Path1], Cost2, Graph, Path, Cost).

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -