Question: Find a path in a weighted graph: ( 1 0 Points ) In the verifier.pl file, there is a representation of the following graph using

Find a path in a weighted graph:
(10 Points)
In the
verifier.pl file, there is a representation of the following graph using predicates to define the
edges as edge (A,B,W) where A and B are the nodes and W is the weight of the edge. Using the
graph representation, write a prolog predicate to find a path in the weighted graph between two
nodes. Along with finding the path, you should also print the total weight obtained while taking
the path determined by your program. The solution should not generate cyclic paths. Note that the
graph is undirected and that the provided edge predicates do not specify a direction. For example,
edge (a,b,1) can be traversed from a to b or from b to a. The goal predicate will take the form:
findpath(x,Y, Weight,Path).
where x,Y= name of the node
Weight = weight of the path taken
Path = path taken in the form of a list
Sample Run:
?- findpath(a,e,Weight,Path).
Path =[a,b,e]
Weight =2;
Path =[a,c,d,e]
Weight =8;
..
File Name:
findpath.pl
Find a path in a weighted graph: ( 1 0 Points )

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!