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 USairports.txt It is an undirected, weighted network of flights among the busiest commercial airports in the United States. The weights represent the number of seats available on the flights between a pair of airports. example: The second dataset is Yeasttxt which represents a directed, unweighted weights all equal to transcription network of operons and their pairwise interactions via transcription factorbased regulation, within the yeast Saccharomyces cerevisiae. Import this network as an undirected network. example: Complete the loadgraphs function to load both the airport and yeast networks from their data files as undirected graphs. Complete the topnodes
function to compute the top nodes according to each of the centrality metrics. Complete the calculatesimilaritymatrix function to compare the top nodes
you obtained from each metric in part using the Jaccard Similarity Index. You will need to implement your own Jaccard Similarity Index based on setwise comparisons to compare the sets of top 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 elementwise operation. Complete the plotsimilarityheatmap 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 loadgraphs:
Returns:
Gairport: NetworkX Graph Object
Gyeast: NetworkX Graph Object
return Gairport, Gyeast. def topnodesG:
Inputs:
G: NetworkX Graph Object
Returns:
topnodesdict: dictlistint
topnodesdict
'eigen': eigen,
'katz': katz,
'pagerank': pagerank,
'closeness': closeness,
'harmonic': harmonic,
'betweeness': betweeness
return topnodesdict. def calculatesimilaritymatrixtopnodesdict:
Inputs:
topnodesdict: dictlistint
Returns:
similaritymatrix: nparray
return similaritymatrix
def plotsimilarityheatmapsimilaritymatrix, dataname, saveFalse:
Inputs:
similaritymatrix: nparray
dataname: str
pltfigurefigsize
pltshow
if save:
pltsavefigfdatanamesimilaritymatrix.png
pltclose
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
