MartijnSmeets
Technical User
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
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