Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
12-11-2020 06:57 AM
Hey guys, so I'm following this guide/excercise on neo4j about a movie database, where I'm also using the same data from there(link here).
Now my problem is trying to find the co-co actors of a particular person. eg Tom Hanks.
co co actors are all the actors who have acted in a movie with a co-actor of Tom Hanks, but have not acted in a movie with Hanks
Now looking at the solutions for exercise 5.4 from the link, my code should look something like this right?
I run the code, but there's no output/records
MATCH (a:Actor)-[:ACTED_IN*2]->(a2:Actor)
WHERE a.name = "Tom Hanks"
AND NOT((a)-[:ACTED_IN]-(a2))
RETURN a2.name AS `co-co-actors``
12-11-2020 02:12 PM
Looks like you posted here and on stackoverflow?
I see the same post over there, with an answer
12-11-2020 02:57 PM
Yes, thats correct Joel.
If, it's okay, can I expand on the question from the answer given on there?
So if a few co-co actors of Tom Hanks appear in multiple movies with Tom hanks co-actors, so for instance Jack nicholas is a co-co actor of Tom Hanks who has acted in more than one movie with Tom hanks co actors. Then we can say that they have multiple paths between Tom and Jack. How would I sort a list according to the number of paths between the two of them? Hopefully my explanation makes sense.
So with what I was explaining, I tried to write the code for it but I'm not sure if what I wrote does what It's suppose to do.
MATCH (tom:Person)-[r1:ACTED_IN]->(m:Movie)<-[r2:ACTED_IN]-(a2:Person)- [r3:ACTED_IN]->(m2:Movie)<-[: ACTED_IN]-(a3:Person)
WHERE tom.name = 'Tom Hanks'
RETURN a3.name,count(m2) as NO_Paths order by NO_Paths desc
All the sessions of the conference are now available online