Skip to content

walk question #3

Answered by ekzhang
webyrd asked this question in Q&A
Nov 30, 2021 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

Thanks for the question! The second rule is needed because you want to find all nodes to start paths in the graph. If your only input relations are edges, then you can find the nodes in the graph implicitly by taking all of the identifiers that are referenced as the start or end of an edge.

Also, now that you point it out, this code sample is a bit misleading, as the underscores don't actually do anything - I'll fix this. It should say

walk(x: v, y: v, len: 0) :- edge(x: v).
walk(x: v, y: v, len: 0) :- edge(y: v).

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by ekzhang
Comment options

You must be logged in to vote
1 reply
@ekzhang
Comment options

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