How to identify relationship dynamically and traverse between nodes to get results in cypher


I have Graph like this below.

Assume I dont know what relation exists between A and D, but I know A and D are related. I want to write a dynamic query which can detect connected to"XXX" without writing the relations between A to D.

I tried something like this but it is not giving correct results. I am expecting A nodes whcih are related to d,name="HEN" but I am getting all A nodes related to D nodes.
MATCH (a:A),(d:D {name:"HEN"}), p = shortestPath((a)-[ * ]-(d))
RETURN distinct a,p,d

Can you let me know how can I achieve this. I want to identify the relation between two nodes first and using that relation between two nodes I want to find out result.

Thanks in Advance

MATCH p=(start:A { name: "Starting Point" })-[*]->(end:D { name: "Ending Point" })

The use of the -[*]-> will match any set of relationships of any type in any order or length. It'll find a path from A to D for you. All of this gets put into a "path variable" called p which gets returned. You can use list functions to then extract out of that all of the nodes and relationships in the middle, if you wish.


I have a relationship as
Does the above solutions holds true for this situation as well.... I haven't tried yet though. (Will do in couple of days)