Edge weights can be adjusted to identify particularly significant edges using a null model. Null models are sets of assumptions that are used to predict the strength of an edge, which can be used to identify edges that surpass those predictions. This might seem familiar because the gravity model that we used in the previous chapter is an example of a null model. Here, we will use a simpler model , assuming that the weight of an edge is proportional to the product of the degrees of the endpoints. The following function takes a Graph as input and produces a new copy with a log_residual edge property representing the deviation of each edge from its predicted weight:
import mathdef residual_net(G): G_residual = nx.Graph(G) # Calculate ...