Write a Python program that will retrieve pages from Wikipedia and compare them using graph analysis.
We want to compare the results of Wikipedia searches on “Aqualung” and “Ian Anderson” (classic rock, good stuff!). This will be 2 separate searches (NOT one search on both terms). Limit each of these searches to 2 “layers” deep in terms of traversing their links. But further limit each breadth-first-search to no more than 50 iterations in the while-loop we don’t want a huge graph! Also, cut down each graph you build to only include nodes that have degree ≥ 2 and no self-loops.
For each of the 2 graphs that you produce (i.e., one for the “Aqualung” search and one for the “Ian Anderson” search), compute Similarity Rank for the nodes in that graph. Output the pairs of nodes in each graph that have similarity ≥ 0.01; so, you’ll have a list of similar nodes for the first graph and a list of similar nodes for the second graph. Don’t just output the indexes of the nodes, output their labels!
Also output the similarity rank value for each pair of nodes. If we weren’t triaging our searches, we would cross-compare similar nodes between the 2 graphs. But there probably will be few, if any, matches between graphs in this assignment.
Next, we want to see what is different between the 2 graphs. To do this using networkx.difference the nodes must be exactly the same in the 2 graphs, which they likely are not! You will have to write code to remove nodes that are in one graph and not in the other, and vice versa1.
After doing the difference, you probably want to remove nodes that have degree 0; they’re probably not as interesting. Use networkx.info to report the main statistics about the difference graph. The graph is probably too big to display it legibly; if you can find a way to do so, you can also include a screenshot showing what it looks like.