Challenge: Degree Centrality

Now for a challenge.

Which actor has directed the most movies?

Use the Neo4j Browser window to the right of the screen to run GDS calls and enter the answer in the box below.

You will need to:

  1. Create a graph projection using the gds.graph.project() procedure.

  2. Include Movie and Actor nodes with the DIRECTED relationship type.

  3. Run the degree centrality algorithm on the projected graph using the gds.degree.stream() procedure.

  4. Order the results to determine which actor has directed the most movies.

Enter the name of the actor (the answer is case sensitive):

  • ✓ Woody Allen

Hint

In the previous lesson, you used the following cypher to find the actors who have acted in the most movies:

cypher
CALL gds.graph.project(
  'proj',
  ['Actor','Movie'],
  'ACTED_IN'
  );

CALL gds.degree.stream('proj')
YIELD nodeId, score
RETURN
  gds.util.asNode(nodeId).name AS actorName,
  score AS numberOfMoviesActedIn
ORDER BY numberOfMoviesActedIn DESCENDING, actorName LIMIT 5

You can modify this to use the DIRECTED relationship to find actors who have directed the most films.

Solution

Woody Allen has directed the most movies in the database. To calculate this, you will need to create a graph projection.

cypher
Create the Projection
CALL gds.graph.project(
    'actor-directors',    // Projection name
    ['Actor', 'Movie'],  // Labels
    'DIRECTED'            // Relationship type
)

Next, run the degree centrality algorithm on the projected graph using the gds.degree.stream() procedure.

cypher
Run the degree centrality algorithm
CALL gds.degree.stream('actor-directors')
YIELD nodeId, score
RETURN
  gds.util.asNode(nodeId).name AS name,
  score AS movies
ORDER BY movies DESC

Summary

In this lesson you learned about centrality in GDS. We went over common use cases and how to run some of the most popular centrality algorithms in GDS.

In the next lesson, you will learn more about Path Finding Algorithms.

Chatbot

Hi, I am an Educational Learning Assistant for Intelligent Network Exploration. You can call me E.L.A.I.N.E.

How can I help you today?