Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is something I got to know as "<strong>agenda search</strong>". While traversing the tree (of data, relations, rules, ...) you maintain an "agenda" (a list) of what to do next. When you enter a node you put its children on the agenda, and then continue with the first element of the agenda, which you pop. This way, if you put new items at the end of the agenda, you get breadth-first. If you put them in front of the agenda, you get depth-first.</p> <p>It's easy to implement with Prolog.</p> <p>EDIT: I might just as well give an implementation hint here. This is a very basic implementation of the agenda search algorithm.</p> <pre><code>agenda_search([N|T],Mode):- doWithNode(N), % do whatever you do the searching for getNodeChildren(N,C), (Mode=bf -&gt; % bf or df (depth-first) append(T,C,A); append(C,T,A)), agenda_search(A,Mode). </code></pre> <p>It relies on external predicates <code>doWithNode</code> that stands for the action you want to perform with each node (e.g. compare node data to a search term, serialize node content, asf.). And <code>getNodeChildren</code> that will bind the list of children of the given node to <code>C</code> (I.e. this predicate actually knows the tree structure and how to find child nodes). Of course the <code>doWithNode</code> predicate might need additional parameters to do its job, which would also show up in the argument list of <code>agenda_search</code>.</p> <p>You can invoke it like this:</p> <pre><code>agenda_search([RootNode], bf) % for breadth-first search </code></pre> <p>and</p> <pre><code>agenda_search([RootNode], df) % for depth-first search </code></pre> <p>I've also found a bit of explanation of the agenda search <a href="http://www.macs.hw.ac.uk/~alison/ai3notes/subsection2_6_2_1.html" rel="noreferrer">on this web page</a>. The nice thing with agenda search is that you can easily switch between the two variants df and bf and play with the results. The algorithm is quite well-behaved memory-wise, as the agenda, the nodes still to explore, only captures a (more or less) small fraction of nodes in the tree at any one time (the so called fringe).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload