Who knows who: from Hollywood to Flanders

16 June 2022
Blog Image

Time for part II, which we hope is more like a godfather sequel, than let’s say a Jaws sequel. Haven't read our first part? You can find it here! In this sequel we try to find connections between different actors and movies they played in. Some of the links are not obvious at first glance, e.g., what is the connection between Zendaya and Audrey Hepburn? Will Smith and Chris Rock? Jacky Lafon and Grace Kelly? Xander De Rycke and Steven Spielberg? Andy Peelman and Steven Seagal. The method to find out those links is the Dijskstra shortest path algorithm.

Dijkstra's algorithm is an algorithm for finding the shortest paths between nodes in a graph, which may represent, for example, road networks, bank transfers, or social networks. Recently it was revealed that the Paradise Papers investigation used Neo4j as a key technology to find connections in leaked data. But we are trying to find out what’s the shortest link between two actors.

Since all actors, actresses, directors, and movies are already in a graph we can find the shortest path with a single command that will instantly return the persons and titles in between. Average query time of the eight examples below is 1.4 seconds on a regular laptop.


  • Create graph based on IMDb data (Here you can go to the first article to check setup).
  • Call shortest path algorithm on graph with a source and target node.
  • Optional: add a weight property to return the ‘most famous’ links based on vote count.
  • Use script to download picture of all people and movies involved in returned shortest path.
  • Use script to resize and crop images, put in plot and add name, movie title and year as info.

We have picked eight examples to illustrate the closeness of Hollywood and by extension the international movie scene:

Unfortunately for Chris Rock, Kevin James did not attend the Oscars. Based on graph analysis, he is the buffer on the shortest path between Will Smith and Chris Rock.

Despite Zendaya being born after Audrey Hepburn passed away, you only need Jake Gyllenhaal and Alan Arkin to connect both.

The same is applicable for Timothée Chalamet and Humphrey Bogart, with Woody Allen and Jossé Ferrer.

Besides an orange beard, there is also a movie link between Bruno Vanden Broecke and Chuck Norris.

Except for their raw talent, there is another connection between Andy Peelman and Steven Seagal.

Besides driving a car with a Jurassic Park logo, you only need three actors to link comedian Xander De Rycke and director Steven Spielberg.

He is known for his charisma, singing, dancing, acting, and is widely regarded as the greatest comic artist of the screen. The other one is Niels Destadsbader.

Not so much actors in the strict sense of the word, but also in the imdb database are Russian president Vladimir Putin and his Ukranian counterpart Volodymyr Zelenskyy. Both are linkable by 3 actor-directors.

Although both talent and fame could differ tremendously, it was still possible to find a link between all examples. Note that, more than one shortest path exists per duo, but we have only showed one for simplicity. Feel free to contact us if you are interested in the shortest link between any two persons or (graph) data analysis in general.