Challenge: Create an actor-director collaboration network
You’ve learned how to create various monopartite projections. Now it’s your turn to create one independently.
In this challenge, you will need to think somewhat outside the box.
All previous monopartite projections have used only one intermediate node. However, this challenge will require you to build your initial Cypher query from two intermediate nodes.
Your task: Create a monopartite projection of Actor nodes connected through directors they’ve both worked with.
This projection would be useful for:
-
Finding actors who’ve worked with the same directors
-
Understanding directorial influence on actor networks
-
Discovering potential casting recommendations
Requirements
Your projection should:
-
Include only
Actornodes -
Connect
Actornodes who have worked with the sameDirectornodes -
Name the projection
'actor-director-network'
Hints
Think about the pattern:
-
ActorA acted in aMovie -
That movie was
DIRECTEDby aDirector -
The same director
DIRECTEDanotherMovie -
ActorB acted in that other movie -
Therefore,
ActorA andActorB are connected through that director
Solution approach
Details
The pattern requires tracing through movies and directors to connect actors:
MATCH (source:Actor)-[:ACTED_IN]->(:Movie)<-[:DIRECTED]-(:Person)-[:DIRECTED]->(:Movie)<-[:ACTED_IN]-(target:Actor) // (1)
WITH gds.graph.project( // (2)
'actor-director-network', // (3)
source, // (4)
target, // (5)
{}, // (6)
{} // (7)
) AS g
RETURN g.graphName AS graph, g.nodeCount AS nodes, g.relationshipCount AS rels // (8)-
Match Actor nodes connected through Movie, Person (director), and Movie nodes
-
Call the GDS projection function
-
Name the projection 'actor-director-network'
-
Include source (Actor) nodes
-
Include target (Actor) nodes
-
First configuration map (empty - using defaults)
-
Second configuration map (empty - using defaults)
-
Return projection statistics
Key components:
-
The MATCH pattern traces through both movies and directors
-
source.name < target.nameprevents duplicates -
The projection connects actors who share directors
-
This is different from direct collaboration (sharing movies)—it reveals directorial networks
Verify your work
Once you’ve created your projection, run degree centrality to find actors who’ve worked with many directors who’ve also worked with many other actors:
CALL gds.degree.stream( // (1)
'actor-director-network' // (2)
)
YIELD nodeId, score // (3)
RETURN gds.util.asNode(nodeId).name AS actor, score AS director_network_size // (4)
ORDER BY score DESC // (5)
LIMIT 10 // (6)-
Call degree centrality in stream mode
-
Run on 'actor-director-network' projection
-
Yield node IDs and degree scores
-
Convert node IDs to actor names and return with scores
-
Sort by score in descending order
-
Limit results to top 10 actors
Actors with high scores are central to directorial networks—they’ve worked with directors who have also directed many other actors.
Finally, try running PageRank on the same network. Replace the graph name to complete the query:
CALL gds.pageRank.stream( // (1)
'?????' // (2)
)
YIELD nodeId, score // (3)
RETURN gds.util.asNode(nodeId).name AS actor, score AS influence // (4)
ORDER BY score DESC // (5)
LIMIT 10 // (6)-
Call PageRank in stream mode
-
Specify the projection name (fill in 'actor-director-network')
-
Yield node IDs and PageRank scores
-
Convert node IDs to actor names and return with scores
-
Sort by score in descending order
-
Limit results to top 10 actors
Check your understanding
Understanding The Projection Pattern
In the actor-director network projection, what does a connection between two actors represent?
-
❏ They appeared in the same movie together
-
✓ They both worked with at least one director in common
-
❏ They both received similar ratings from users
-
❏ They both appeared in movies of the same genre
Hint
Think about what intermediate nodes the projection pattern traces through to connect the two actors.
Solution
They both worked with at least one director in common is correct.
The projection pattern Actor → Movie ← Director → Movie ← Actor connects actors through shared directors. This is different from direct collaboration (sharing the same movie) or other types of connections. It reveals which actors are part of the same directorial networks.
Comparing Network Types
You create two monopartite actor projections:
-
'actor-collaboration': Actors connected through shared movies -
'actor-director-network': Actors connected through shared directors
What’s the key difference in insights these reveal?
-
❏ They reveal the same information, just calculated differently
-
✓ Collaboration shows direct co-stars; director network shows broader industry connections through directors
-
❏ Director network is always smaller than collaboration network
-
❏ Collaboration network includes directors; director network doesn’t
Hint
Think about what each network tells you about relationships in the film industry.
Solution
Collaboration shows direct co-stars; director network shows broader industry connections through directors is correct.
These projections reveal different aspects:
-
Actor collaboration: Direct working relationships (who appeared in the same film)
-
Actor-director network: Industry connections through shared directors (who’s in the same directorial ecosystem)
An actor might have high centrality in the director network without ever appearing in the same movie as those connected actors—they’re connected through the directors they’ve all worked with.
Summary
Creating monopartite projections requires understanding the relationship patterns that connect nodes of the same type. The actor-director network demonstrates a more complex projection than simple collaboration—connecting actors through shared directors rather than shared movies.
This type of projection reveals different network dynamics:
-
Direct collaboration (Actor → Movie ← Actor): Who worked together
-
Director network (Actor → Movie ← Director → Movie ← Actor): Who shares directorial connections
Both are monopartite actor networks, but they reveal different aspects of the film industry ecosystem.
Next, you’ll learn about bipartite graphs and when preserving two distinct node types matters for analysis.