Can we input three points for a node network

cypher
knowledge-base

(Sucheta) #1

Hi,

I am seeking a query where in i can input three nodes and i can tranverse through those three nodes .
Eg .

         department             system                       API                       Request
ICICI -----------------> IT -------------->  Disconparams----------> FDR Addition --------------> StoreAccount

where department,system,API,Request are relationships and rest are nodes

i only have the names of nodes ICICI, Disconparams and StoreAccount. So is there a cypher query that can include all these three nodes and traverse through its path. say here there are several API 's in the path that disects and creates branches and so i specifically want to traverse through this path only.

Regards,
Sucheta


(Andrew Bowman) #2

That seems straight forward, you just need to MATCH the pattern with the predicates so you are looking up each of those 3 specific nodes by property. Use EXPLAIN on the query to see how the planner plans to execute this.

You should have indexes on the relevant label/property combinations for fast lookup of each of the nodes, and you can use index hints to force the planner to do an index lookup for each of the nodes if it's not doing this already.

Give it a try, and if you run into trouble let us know, along with the query you attempted.


(Sucheta) #3

Hi Andrew,

I checked out index hints. But i don't know the node label.
I even don't know in what sequence do the nodes appear. So i tried shortestPath query.


MATCH (personA { name: "ABC Addition" }),
      (personB { name: "input" }),
      (personC { name: "payload" }), (personD  { name: "ABC"})
WITH personA, personB, personC,personD
MATCH p = shortestPath((personA)-[*]-(personB))
MATCH p2 = shortestPath((personB)-[*]-(personC))
MATCH p3 = shortestPath((personD)-[*]-(personA))
RETURN p, p2,p3

The index hints query which didn't work -

MATCH (liskov  { name: "ABC Addition" })-[*]->(wing)-[*]->(cs { name: "input" })-[*]->(conway { name: "payload"})
RETURN liskov,cs,conway

But i would require a little help here.
Since i don't know the sequence and i also want only the relevant network to touch the bottom , i used the query -

MATCH (personA { name: "FDR Addition" }),
      (personB { name: "input" }),
      (personC :Parameter), (personD  { name: "ICICI"})
WITH personA, personB, personC,personD
MATCH p = shortestPath((personA)-[*]-(personB))
MATCH p2 = shortestPath((personB)-[*]-(personD))
MATCH p3 = shortestPath((personA)-[*..3]-(personC))
RETURN p, p2,p3

Like it did the relationship match till 3 levels. However, is there a way to figure out the last relationship only for the relevant network and not go beyond it.
Thank you for your assistance.


(Andrew Bowman) #4

Since you don't know the labels, you can't use index lookup, and these will be using inefficient all nodes scans. If there is any way you can have labels present in some way, even some general label that can be applied to all your nodes, then it will be possible to create an index and use index lookup.

As for the paths, it looks like you don't know what relationships are connecting these nodes. Are the nodes you previously matched to supposed to be the only nodes making up each path? Right now your queries are finding paths between these nodes, but the nodes in between them may be nodes other than the ones you are matching to.


(Sucheta) #5

Hi andrew,

The entire network is connected and the nodes FDR Addition, input and ICICI are specifically connected . Please check -

Here , in the above photo , the Parameter relationship is the last. But this is due to the query. There are Parameters even beyond payload , header,signature nodes. We have implemented an Apriori Algorithm from where we get the retrieve the top five sequences. This sequence is a set of nodes. These nodes are arranged in random order. I want to retrieve the shortest path between these nodes where we get the output till immediate Parameter and not for Parameters beyond that.

Please help.