Skip to content

Return a subgraph touched by a query #241

Answered by ryanjshaw
mikebellerU asked this question in Q&A
Discussion options

You must be logged in to vote

Have you found a solution? It's my understanding that Datalog-style languages answer queries by repeatedly applying rules to facts until they reach a fixpoint (i.e. the rules don't produce new information), and then the query itself is evaluated. While theoretically it seems possible to keep a record of what rule produced which new fact, it doesn't seem like CozoDB implements this. Instead, as far as I can tell, you need to track this information explicitly yourself, e.g.:

edge[f, t] <- [['A', 'B'], ['B', 'C'], ['C', 'D']]
path[x,y,via] := edge[x,y], via=[[x,y]]
path[x,z,via] := path[x,y,_via], edge[y,z], via=concat(_via,[[y,z]])

?[from,to,via] := path[from,to,via], from = 'A', to ='D'

p…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@MikeBeller
Comment options

@aramallo
Comment options

Answer selected by mikebellerU
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants