Challenge: Monopartite projection

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:

  1. Include only Actor nodes

  2. Connect Actor nodes who have worked with the same Director nodes

  3. Name the projection 'actor-director-network'

Hints

Think about the pattern:

  • Actor A acted in a Movie

  • That movie was DIRECTED by a Director

  • The same director DIRECTED another Movie

  • Actor B acted in that other movie

  • Therefore, Actor A and Actor B are connected through that director

Solution approach

Details

The pattern requires tracing through movies and directors to connect actors:

cypher
Solution: Project actors connected through directors
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)
  1. Match Actor nodes connected through Movie, Person (director), and Movie nodes

  2. Call the GDS projection function

  3. Name the projection 'actor-director-network'

  4. Include source (Actor) nodes

  5. Include target (Actor) nodes

  6. First configuration map (empty - using defaults)

  7. Second configuration map (empty - using defaults)

  8. Return projection statistics

Key components:

  • The MATCH pattern traces through both movies and directors

  • source.name < target.name prevents 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:

cypher
Run degree centrality on actor-director network
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)
  1. Call degree centrality in stream mode

  2. Run on 'actor-director-network' projection

  3. Yield node IDs and degree scores

  4. Convert node IDs to actor names and return with scores

  5. Sort by score in descending order

  6. 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:

cypher
Run PageRank on actor-director network (replace ?????)
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)
  1. Call PageRank in stream mode

  2. Specify the projection name (fill in 'actor-director-network')

  3. Yield node IDs and PageRank scores

  4. Convert node IDs to actor names and return with scores

  5. Sort by score in descending order

  6. 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:

  1. 'actor-collaboration': Actors connected through shared movies

  2. '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.

Chatbot

How can I help you today?