Getting most frequently occurring pairs of co-actors with an actor in Neo4j

Viewed 409

My question is nearly same as Finding triplets having highest common relationships in Neo4j But the answer provided is not solving the purpose. My database has two types of nodes. Movies and Actors. I want to find the most frequent pairs of co-actors for a given actor. So, if an actor has acted in 100 movies, I want to find most common pairs of co-actors in those 100 movies.

Database type
(:Movie)-[:STARS]->(:Actor)

I can get the most frequent co-actors in a list of descending order by frequency following the CQL

MATCH (actor1:Actor)<-[st1:STARS]-(mv1:Movie)-[st2:STARS]->(actor2:Actor) 
WHERE actor1.name = "Tom"

RETURN actor1,actor2,count(mv1)

ORDER BY count(mv1) DESC

mentioned in the question itself. But the answer posted is not returning me with pairs of co-actors The answer I am looking for is as follows

Actor1  Actor2  Actor3  Count(Movie)
A         B       C          20
A         B       D          10

This table can hypothetically imply that A has starred in 25 unique movies and in those movies B and C are together as well in 20 and B and D are together in 10

0 Answers
Related