8.4. Anna Karenina Network Assignment¶
the graph for *Anna Karenina* (AK). Following
the model used in analyzing Les Miserables in
the ipython notebook demo for networkx, draw
a graph for AK that labels only the top 10 most
All the points covered here are covered Help with this homework assigned for this module is also available in the notebook [github_repo]/networkx/network_module/merged_using_networkx.ipynb.
Experiment with adding 20 more characters to the top characters shown. You will be turning in
whatever images you think are the best (possibly more than 1 because different images may have different advantages);
The identity of the edge that has the highest weight (that is, the pair of characters that have appeared in the most scenes together) and what that weight is (the number of shared scenes). Since all the
networkxbetweenness functions return dictionaries, the following code snippet may be of use. It extracts a ranked list from dictionary
DD:>>> L = [x for x in sorted(DD.items(),key=lambda x: x,reverse=True)]
An example of two characters that do not have an edge between them (they share no scenes).
Consider the Florentine Families graph, which depicts the alliances among Renaissance Florentine familes, as established by marriage ties. It so happens this graph can be constructed in
G = nx.florentine_families_graph(). Run classical
nx.betweenness_centralityon this graph (see Section Introduction to Networkx), find the most central families, and compare the results with random walk betweenness_centrality, also available as
nx.current_flow_betweenness_centrality. Does a different family get chosen as the most central?
Experiment with different layout algorithms. This will require a trip to
networkxdocumentation pages (in particular, the Drawing section of the reference manual).
The model for Les Miserables discussed in class only introduced you to Betweenness Centrality as a measure of centrality. Experiment with ranking nodes by Degree-centrality instead of Betweenness-Centrality. Then use top 10 most important nodes as chosen by degree centrality in drawing a graph. Are the result images better, worse, pretty much the same? Discuss why.
Read Mark Newman’s paper on
random walk betweenness centrality. There may be things you don’t understand, but soldier on and read the part in which he discusses applying his new model to examples. At the very end he talks about the results of his new centrality measure on the Florentine Families graph, which depicts the alliances among Renaissance Florentine familes, as established by marriage ties. As noted above, this graph can be constructed in
G = nx.florentine_families_graph(). Relate the differences you saw above when ran
nx.random_walk_betweenness_centarlityto Newman’s discussion.