Question: Complete the calculate _ inter _ community _ density function to calculate the intercommunity connection density matrix ( see matrix P in L 1 2
Complete the calculateintercommunitydensity function to calculate the
intercommunity connection density matrix see matrix P in L: Generating Networks
with Community Structure for the definition
Additionally, complete the plotpmatrix function to plot the intercommunity detection
density matrix as a heatmap. Make sure to annotate the values within each cell and
provide a legend.
def calculateintercommunitydensityG: nxGraph, partition: list Tuplenpndarray, Listint:
Inputs:
G: NetworkX graph object
partition : list
Returns:
Tuple of np array and Listint intercommunity connection density matrix
return p sizes
def plotpmatrixp: npndarray, save: boolFalse:
Inputs:
p: np array, intercommunity connection density matrix
save: boolean
Returns:
None
if save:
pltsavefigpng
pltshow
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
