Różnice
Różnice między wybraną wersją a wersją aktualną.
|
|
pl:prolog:pllib:depth-first_search_3 [2019/06/27 15:50] |
pl:prolog:pllib:depth-first_search_3 [2019/06/27 15:50] (aktualna) |
| ====== Depth-first search 3 ====== |
| {{tag>trees searching}} |
| ===== Description ===== |
| A depth-limited, depth-first search program. |
| |
| **Source**: PROLOG programming for artificial intelligence, 3rd Edition, Harlow, 2001, ISBN 0-201-40375-7. |
| ===== Download ===== |
| Program source code: {{depth-first_search_3.pl}} |
| ===== Listing ===== |
| <code prolog> |
| % Figure 11.8 A depth-limited, depth-first search program. |
| |
| |
| % depthfirst2( Node, Solution, Maxdepth): |
| % Solution is a path, not longer than Maxdepth, from Node to a goal |
| |
| depthfirst2( Node, [Node], _) :- |
| goal( Node). |
| |
| depthfirst2( Node, [Node | Sol], Maxdepth) :- |
| Maxdepth > 0, |
| s( Node, Node1), |
| Max1 is Maxdepth - 1, |
| depthfirst2( Node1, Sol, Max1). |
| |
| |
| </code> |
| ===== Comments ===== |
| |