You can use the WITH clause for the aggregate function COUNT(). You can apply COUNT() to either relationship or the "Movie" node to get the number of movies for each actor in the node label "Person".
Here are two queries that will return the same output:
Using relationship
MATCH (p:Person)-[r:ACTED_IN]-(m:Movie)WITH p.name as actor, count(r) as movieCountRETURN actor, movieCount;
MATCH (p:Person)-[r:ACTED_IN]-(m:Movie)
WITH p.name as actor, count(r) as movieCount
RETURN actor, movieCount;
Using Movie node
MATCH (p:Person)-[r:ACTED_IN]-(m:Movie)WITH p.name as actor, count(m.title) as movieCountRETURN actor, movieCount;
WITH p.name as actor, count(m.title) as movieCount