I have a graph with the following relationships:
A -> B -> C & A-> C.
And I want to show All A->C instances including the implied ones (A->B->C).
A(John) -> Works_At -> C(Apple)
A(Tony) -> has_ID ->B(123)
B(123) -> IsEmployedAt -> C(Facebook)
I want to visualize in one view:
Can someone please help me with this.
I have tried creating a virtual relationship A->B->C but it returns no results.
A union may give you what you want, something like this (still slightly pseudo code, but more cypher like)
either directly as a list or as input to create the virtual relationships? Though, I suspect you might also want to do a distinct A,C after the UNION to avoid potential duplicates.
The following query might solve your problem:
Optional Match (b)-[:IS_EMPLOYEED_AT]->(c)
Return a.name As
When b.name is null
In this query we can use the regular expression operator union over the edge labels to find both company and empid of the person if such relationships in the database exist.
Then the optional match is used to search if node b has an outgoing edge to the company node and the edge label is :IS_EMPLOYED_AT. The optional match returns null if no such edges and subsequent nodes exists.
In case you just wish to visualize the relationships found by the MATCH clause then in the return clause simply return a,b,c