Question
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
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 2 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?
(b) Are all nodes of the graph reachable from the node n?
(c) Does the graph have a directed cycle?
(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)
(e) Which pairs of nodes are connected by a path with an even number of a labels?
(f) Which pairs of nodes are connected by a path with the same number of a and b labels?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started