Problem
A graph G has a set of edges defined by
edge(U,V,W)
meaning there is an edge from U to node V with cost W.
Trying to find:
(a.) clause path(S,D) which succeed if there is a path from S to D
(b.) clause pathcost(S,D,Cost) returns the cost from S to D
(c.) clause thepath(S, D, Path) returns, in Path, a list fo the nodes on the path from S to D including S and D.
My solution(I am on the correct path)
(a.)
edge(S,D)
path(S,D) :- edge(S,D);edge(D,S)
(b.)
edge(S,D,Cost)
pathcost(S,D,Cost):- travel(A,B,[A],Q), reverse(Q,Path)
(c.)
thepath(S,D,Path)
travel(S,D,P,[D|P]) :-connected(S,D).
Any explanation to help my understanding is appreciated.
Prolog and graphs
Started by chetah, Apr 05 2009 12:31 PM
7 replies to this topic
#1
Posted 05 April 2009 - 12:31 PM
#2
Posted 05 April 2009 - 12:56 PM
This is a homework question?
#3
Posted 05 April 2009 - 02:04 PM
No not home work. Trying to work an example associated to this site I am working on
http://www.csupomona.../pt_framer.html
http://www.csupomona.../pt_framer.html
#4
Posted 05 April 2009 - 04:12 PM
If you're not doing homework, why bother learning Prolog? No one outside academia uses it.
reedbeta.com - developer blog, OpenGL demos, and other projects
#5
Posted 05 April 2009 - 04:25 PM
Reedbeta said:
If you're not doing homework, why bother learning Prolog? No one outside academia uses it.
OH, COME ON, THAT'S JUST PLAIN CRAZY!!!!!!!
I use it for proof of concepts even of graphical tasks all the time and I have friends that use it too and I know many many useful things in it that are not available in other languages, so just never say the 'outside academica'-part for logical programming, ASP and CSP again please.
#6
Posted 05 April 2009 - 04:29 PM
I stand corrected.
reedbeta.com - developer blog, OpenGL demos, and other projects
#7
Posted 05 April 2009 - 11:31 PM
Yeah, come on. No absolutes. Let's just settle for 1 in 10 trillion billion people use it ;)
I can't believe uni's are still teaching this dead crap. I can accept it might have a use somewhere sometime, but students should be learning stuff they're gonna use *all* the time when they go into the real world. C++ and maybe some java or python or c# or other clone
I can't believe uni's are still teaching this dead crap. I can accept it might have a use somewhere sometime, but students should be learning stuff they're gonna use *all* the time when they go into the real world. C++ and maybe some java or python or c# or other clone
#8
Posted 07 April 2009 - 05:18 PM
I'm closing this thread since it is not gamedev related.
reedbeta.com - developer blog, OpenGL demos, and other projects
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


This topic is locked









