Question: 1. Consider databases that encode a labelled, directed graph by means of a ternary EDB predicate e (edge). The first two parameters are the source

 1. Consider databases that encode a labelled, directed graph by means

of a ternary EDB predicate e ("edge). The first two parameters are

1. Consider databases that encode a labelled, directed graph by means of a ternary EDB predicate e ("edge). The first two parameters are the source and target nodes of the edge, while the third parameter is its label. For example, the fact e(m, n, a) represents an edge from m to n labelled with a. Moreover, assume that only constants a and b are used as labels. Can you express the following queries using Datalog? If your answer is yes, provide the query, otherwise provide a brief justification of why this is not the case. (a) Which nodes in the graph are reachable from the node n?" [1 mark] (b) Are all nodes of the graph reachable from the node n?" [1 mark] (C) Does the graph have a directed cycle?" [1 mark] (d) Does the graph have a path that is labelled by a palindrome?" (a palindrome is a word that reads the same forwards and backwards) [1 mark] (e) Which pairs of nodes are connected by a path with an even number of a labels? [1 mark] (f) Which pairs of nodes are connected by a path with the same number of a and b labels?" [1 mark]

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!