Its called "Six Degrees of Kevin Bacon" and the directions are relatively complex and outlined here:
The concept is simple, but finding the smallest number of links can be difficult. The way you link an actor with Bacon is like so:
Pick a film actor, any film actor.
Link the actor you've chosen to Bacon via the movies they've shared with other actors until you end up with Kevin Bacon himself.
Here is an example, using Elvis Presley:
Elvis Presley was in Change of Habit (1969) with Edward Asner
Edward Asner was in JFK (1991) with Kevin Bacon
Therefore Elvis Presley has a Bacon number of 2.
The game has expanded to become more about linking two film actors than just one actor to Kevin Bacon. The name is still retained, however, because it has been shown that Bacon is a common link member in a chain.
https://en.wikipedia.org/wiki/Six_Degrees_of_Kevin_Bacon#The_concept