In a game theory class I took in college, we spent some time learning about social networks and graph theory.

Basically, a graph consists of nodes (individuals who interact in a network) and edges (the connections between the individuals).

The PageRank algorithm, originally the basis for Google's ordering of search results, defines nodes as webpages, and edges as the links between the webpages. Sites are ranked based on how many incoming and outgoing links they have with other sites in the network -- with the underlying assumption that the more important or influential a site is, the more links it will receive.

I wondered if the same framework could be applied to hockey... that is, can we use the links between players involved in goals (the scorer and the assister) to calculate their PageRank and measure how important they are to their team?

Here's what I came up with. Using the igraph and nhlscraper packages in R, I created graphs for each team in the NHL. The images above depict the goal-scoring graphs for the Nashville Predators and Pittsburgh Penguins.

Right away, we can see which players are the most involved in their teams’ respective offenses. Sidney Crosby (second only to Connor McDavid in points), has the largest PageRank. Filip Forsberg was the leader for the Preds.

Photo credit: SI.com

However, PageRank is easily influenced by collusion between nodes in the network. It can be manipulated by ‘cartels’ of individuals/web pages that link to each other repeatedly in order to inflate their score.

In hockey, the analogue to this is the impact that linemates have on each others’ point totals. Players who are frequently on the ice together, will naturally have more connections (edges) of goals/assists with each other.

I haven’t yet attempted to adapt the PageRank algorithm to account for the interconnectedness of linemates – but I have been able to quantify this effect.

‘Chemistry’ has always been a difficult concept to measure in sports. But by calculating the ratio of players’ PageRank while on the ice with their linemates, to their overall PageRank regardless of who is on the ice, I was able to approximate this phenomenon.

Below are the top 10 lines (from the 16-17 season) with the most chemistry, according to my metric:

edit: found an error in my code. Here are the new top 10:

Edmonton: Leon Draisaitl, Patrick Maroon, Connor McDavid

2. Boston: David Pastrnak, Patrice Bergeron, Brad Marchand

3. Chicago: Patrick Kane, Artem Anisimov, Artemi Panarin

Photo credit: sportsnet.ca

4. Anaheim: Rickard Rakell, Ryan Getzlaf, Corey Perry

5. Dallas: Jamie Benn, Jason Spezza, Tyler Seguin

6. New Jersey: Taylor Hall, Travis Zajac, Kyle Palmieri

7. Winnipeg: Nikolaj Ehlers, Mark Scheifele, Patrik Laine

8. New York: John Tavares, Josh Bailey, Anders Lee

9. Nashville: Viktor Arvidsson, Ryan Johansen, Filip Forsberg

10. Montreal: Max Pacioretty, Alexander Radulov, Phillip Danault

(The line of Sidney Crosby, Conor Sheary, and Jake Guentzel was #1 in the playoffs).