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.

Find longest path over 2 relationship types

I've followed the following guide to find a longest path when a single relationship is at play https://neo4j.com/developer/kb/achieving-longestpath-using-cypher/.

However my model, of DNS resolution, looks like the following:

(Host)-[ALIAS_FOR]->(DNSRecord)-[RESOLVES_TO]->(Host)

Any host outside of our DNS is the final destination e.g. a heroku app or S3 bucket.

I want to write a query that, given a host, traverses as far as the final host that does not have an ALIAS_FOR relationship.

There is the simple case of non-bifurcating chains, but there is also the bifurcating case to consider (for geo-specific DNS routing a host may be an alias for multiple DNSRecords).

As a nice to have, it'd be good if it could handle chains of length 1 (i.e. the Host provided has no ALIAS_FOR relationship)

The only way of tackling this problem I can think of is APOC virtual relationships https://neo4j.com/docs/labs/apoc/current/virtual/, but I wonder if there is a native cypher way?

0 REPLIES 0