def simulate_walks(self, num_walks, walk_length, stay_prob=0.3, workers=1, verbose=0): layers_adj = pd.read_pickle(self.temp_path + 'layers_adj.pkl') layers_alias = pd.read_pickle(self.temp_path + 'layers_alias.pkl') layers_accept = pd.read_pickle(self.temp_path + 'layers_accept.pkl') gamma = pd.read_pickle(self.temp_path + 'gamma.pkl') walks = [] initialLayer = 0 nodes = self.idx # list(self.g.nodes()) results = Parallel( n_jobs=workers, verbose=verbose, )(delayed(self._simulate_walks) (nodes, num, walk_length, stay_prob, layers_adj, layers_accept, layers_alias, gamma) for num in partition_num(num_walks, workers)) walks = list(itertools.chain(*results)) return walks
def parallel_walks(self, num_walks, walk_length, workers=1, verbose=0): G = self.G nodes = list(G.nodes()) results = Parallel(n_jobs=workers, verbose=verbose, )( delayed(self._parallel_walk)(nodes,num, walk_length) for num in partition_num(num_walks, workers)) walks = list(itertools.chain(*results)) return walks