alpha_ij_out = 1 - (k_out - 1) * integrate.quad(lambda x: (1 - x) ** (k_out - 2), 0, p_ij_out)[0]
N.add_edge(u, v, weight=w, alpha_out=float("%.4f" % alpha_ij_out))
elif k_out == 1 and G.in_degree(G.successors(u)[0]) == 1:
// we need to keep the connection as it is the only way to maintain the connectivity of the network
v = G.successors(u)[0]
w = G[u][v][weight]
After Change
alpha_ij_out = 1 - (k_out - 1) * integrate.quad(lambda x: (1 - x) ** (k_out - 2), 0, p_ij_out)[0]
N.add_edge(u, v, weight=w, alpha_out=float("%.4f" % alpha_ij_out))
elif k_out == 1 and G.in_degree(list(G.successors(u))[0]) == 1:
// we need to keep the connection as it is the only way to maintain the connectivity of the network
v = list(G.successors(u))[0]
w = G[u][v][weight]