Re: Need advice for path research

Timo Karjalainen <[email protected]>
Newsgroups gmane.comp.gnu.prolog.general
Message-ID <[email protected]>
Hi Gurvan,

> path(From, To, [From, To]) :- rel(From, To).
> path(From, To, [From | Tail]) :-
>    rel(From, Intermediate),
>    path(Intermediate, To, Tail).
> 
>  How would you prevent an element to appear twice in the path?

You need to keep track of the nodes that you've visited already. Then  
you check that the Intermediate given by rel/2 is not in the set of  
already visited nodes.


-- 
TOK
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.