June 2020
Intermediate to advanced
382 pages
11h 39m
English
Let's create a network and then try to calculate its centrality metrics. The following code block illustrates this:
import networkx as nximport matplotlib.pyplot as pltvertices = range(1,10)edges = [(7,2), (2,3), (7,4), (4,5), (7,3), (7,5), (1,6),(1,7),(2,8),(2,9)]G = nx.Graph()G.add_nodes_from(vertices) G.add_edges_from(edges)nx.draw(G, with_labels=True,node_color='y',node_size=800)
The graph produced by this code is as follows:

So far, we have studied different measures of centrality. Let's calculate them for the preceding example:
Note that the metrics of centrality are expected to give the centrality ...