Calculate distance to node? #155
jcpsantiago
started this conversation in
General
Replies: 1 comment
-
|
try using: (->> (q '[:find ?a ?n :in ?k ?x :where [?n :attr ?x] [?k ?a+ ?n]] db k x :planner :user)
(map (fn [[a n]] [(count a) n])))I don't know is the What happens is that if a transitive attribute between 2 bound nodes is selected, then it returns a vector containing the shortest path between those nodes. Since the transitive attribute is at the back of the query here (and it's forced to stay at the back by using the "user planner") then it won't be bound until the ?n is bound, and you're already specifying the ?k. So the ?a value will be a vector. You'll need to keep it with the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I used Neo4J to learn about graph databases, but wanted to experiment with something implemented in Clojure. Thanks for creating Asami ;)
Something I used a lot in Neo4J was the ability to calculate distances between nodes. This is important in my domain (anti-fraud), and I wanted to use these distances as downstream features in machine learning models. Reading through Asami's docs I see examples for questions like "is the current node connected to any other node with attribute x?" but not "what's the minimum number of hops from node k to any node with attribute x?" -- is this not possible at all, or I just missed how to do that in the docs?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions