cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Is a relation vector possible in neo4j?

Hi everyone,
is it possible to follow a relationship vector in Neo4j? The key word here is the start of the vector.
For example , I have the following dataset: (:node {name:A})-[:supplies]->(:node {name:B)-[:supplies]->(:node{name:C})-[:supplies]->(:node{name:D})

I would like to be able to define beginning for my query. For example - get all nodes which node C supplies. Currently my query returns all nodes - A,B,C and D, even though I start from node C. So is there a vectoring query, where I am able to set a start in the dataset and follow a direction? In other word to receive node D only?
And I don't mean to use the WHERE clause manually for this particular example. In my app the nodes chain might be hundreds, being input via a webapp, and each node might have different owner. So I need a function in which I can set a starting node and follow direction in the relation

2 REPLIES 2

Jiropole
Graph Voyager

Hey, post your actual code, outline your use case in regards to a detailed model.

Yes, you just need to use a variable-length relationship pattern, and ensure you include the direction of the relationships as well as make sure your starting node is defined.

An index or unique constraint to support the lookup of your starting node is also important, so ensuring something like CREATE INDEX ON :node(name) will help.

MATCH (:node {name:'C'})-[:supplies*]->(n:node)
RETURN n.name as nodeSuppliedByC