# calculate weights of all possible edges w = gi.calc_weight(pos, k) # initialize the list to store all the edge list in the type of string edge_list = [None] * 0 # write initial edge list into edge_list[0] as a string edge_list.append(str(tmp.edges())) # get the the number of neighbors of node 0 neighbor_0 = len(tmp.neighbors(0)) # get the number of edges in the whole graph n_edge = tmp.number_of_edges() # check necessary edges of the zeroth graph keep_i = ug.chk_bridges(tmp) # calculate the inverse of probability q(j|i) for the zeroth graph prob_i = mc.calc_prob(keep_i, etot) # calculate thetas for zeroth graphs theta_i, max_i = mc.calc_theta(tmp, w, r) # sum the maximum length sum_max_len = max_i # I/O part expectations = open('output', 'w') edges = open('edgelist', 'w') summary = open('summary', 'w') # output information print('{}{}'.format('total number of nodes: ', k), file=summary) print('{}{}'.format('nodes positions: ', pos), file=summary) print('{}'.format(tmp.edges()), file=edges) print('{}{}{}{}{:6d}{:9.4f}{:9.4f}{:9.4f}'.format('nsteps ', 'degree_0 ', 'n_edges ', 'max_len', 1, neighbor_0, n_edge, sum_max_len),