Now let's calculate the degrees of separation between any two pages. This answers the question of how many pages we need to go through from a source page to find another page. This could be a non-trivial graph traversal problem as there can be multiple paths between the two pages. Fortunately for us, NetworkX, using the exact same graph model, has built in function to solve this with the exact same model from the previous recipe.
Calculating degrees of separation
How to do it
The script for this example is in the 08/07_degrees_of_separation.py. The code is identical to the previous recipe, with a 2-depth crawl, except that it omits the graph and asks NetworkX to solve the degrees of separation between Python_(programming_language...