Question: A DAG is a directed a cyclic graph. edge list representation of the format edge ( v 1 , v 2 , cost ) for

A DAG is a directed a cyclic graph.
edge list representation of the format edge(v1, v2, cost) for the graph:
edge(a, b,2).
edge(a, d,1).
edge(a, e,1).
edge(a, a,0).
edge(b, c,6).
edge(b, e,2).
edge(b, b,0).
edge(c, e,9).
edge(c, c,0).
edge(d, c,10).
edge(d, f,7).
edge(d, d,0).
edge(e, f,8).
edge(e, e,0).
edge(f, f,0).
In prolog, write a predicate dagPaths(S, F, Path, Cost) that lists all Paths from vertex S (start) to vertex F (finish)
along with the total cost of the Path.
examples:
?- dagPaths(b, b, Path, Cost).
Path =[b],
Cost =0;
false.
?- dagPaths(b, f, Path, Cost).
Path =[b, c, e, f],
Cost =23;
Path =[b, e, f],
Cost =10;
false.

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 Databases Questions!