Prolog problem
- From: "Martijn Smeets" <info[at]msphotographics.nl>
- Date: Wed, 19 Oct 2005 21:03:50 +0200
I have the following prolog problem, I just don't know how to solve..
I hope somebody is able to help me out...
I have to build the following:
A program that checks a Directed Graph if there's a cycle that ends at it's
beginning, and visits each point just once.
The graph should be used as a structure graph(Points, Vertices).
A vertex from a to b is presented like [a,b].
The shape of the routine that should be called:
tour(graph(Points, Vertices),Tour)
Like:
tour(graph([a,b,c,d], [[a,b],[b,b],[b,d],[d,c],[c,a]]),Tour).
Tour = [a,b,d,c,a]
yes
tour(graph([a,b,c], [[a,b],[b,b],[a,c],[b,c]]),Tour).
no
Who's able to write such a programm. I guess it shouldn't be too hard, but
I'm just not good at prolog. I have to have a solution by this weekend.
Any help would be appreciated.
Wit regards,
Martijn Smeets
.
- Follow-Ups:
- Re: Prolog problem
- From: Martijn Smeets
- Re: Prolog problem
- From: A . L .
- Re: Prolog problem
- Prev by Date: Re: Negation In Prolog
- Next by Date: Re: Problem to understand "Prolog Vocabulary"
- Previous by thread: [NEWBIES] Problem to understand "Prolog Vocabulary"
- Next by thread: Re: Prolog problem
- Index(es):