These 2 queries seem to be somewhat similar thought they return very different results.
match (fof:Person)-[:HAS_CONTACT*2]-(p:Person{name:"Tom Hanks"})-[:ACTED_IN]->(m:Movie)
where fof<>p
with collect(distinct fof.name) as f
return f, size(f)
vs
match (p:Person{name:"Tom Hanks"})-[:HAS_CONTACT*2]-(fof:Person)-[:ACTED_IN]->(m:Movie)
where fof <> p
with collect(distinct fof.name) as f
return f, size(f)
The :HAS_CONTACT relationship is an arbitrary relationship. See dataset here: Neo4J-GraphDB-Foundations/create-course-data.cypher at master · Manish-Giri/Neo4J-GraphDB-Foundations · GitHub