Question: Calculate and plot six different centrality metrics for two different data sets. The first data set is US _ airports.txt . It is an undirected,

Calculate and plot six different centrality metrics for two different data
sets. The first data set is US_airports.txt. It is an undirected, weighted network of flights among the 500 busiest commercial airports in the United States. The weights represent the number of seats available on the flights between a pair of airports. (example: 1471) The second dataset is Yeast.txt which represents a directed, unweighted (weights all equal to 1) transcription network of operons and their pairwise interactions via transcription factor-based regulation, within the yeast Saccharomyces cerevisiae. Import this network as an undirected network. (example: 11941).1) Complete the load_graphs function to load both the airport and yeast networks from their data files as undirected graphs. 2) Complete the top_10_nodes
function to compute the top 10 nodes according to each of the centrality metrics. 3)Complete the calculate_similarity_matrix function to compare the top 10 nodes
you obtained from each metric in part 1.1 using the Jaccard Similarity Index. You will need to implement your own Jaccard Similarity Index based on set-wise comparisons to compare the sets of top 10 nodes coming from different centrality metrics - do not rely on existing packages because the similarity we are expecting is defined on sets, while some package implementations perform an element-wise operation. Complete the plot_similarity_heatmap function to plot the similarity index using a
heatmap of the data that has the following format, but populating it with your own index values. Note: You must display the actual index values. which centrality
metric would you consider to be the most relevant for these networks? Justify your
answer. def load_graphs():
"""
Returns:
G_airport: NetworkX Graph Object
G_yeast: NetworkX Graph Object
"""
return G_airport, G_yeast. def top_10_nodes(G):
"""
Inputs:
G: NetworkX Graph Object
Returns:
top_10_nodes_dict: dict[list[int]]
"""
top_10_nodes_dict ={
'eigen': eigen,
'katz': katz,
'page_rank': page_rank,
'closeness': closeness,
'harmonic': harmonic,
'betweeness': betweeness
}
return top_10_nodes_dict. def calculate_similarity_matrix(top_nodes_dict):
"""
Inputs:
top_nodes_dict: dict[list[int]]
Returns:
similarity_matrix: np.array
"""
return similarity_matrix
def plot_similarity_heatmap(similarity_matrix, data_name, save=False):
"""
Inputs:
similarity_matrix: np.array
data_name: str
"""
plt.figure(figsize=(7,7))
plt.show()
if save:
plt.savefig(f'{data_name}_similarity_matrix.png')
plt.close().

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!