(self, graph, walk_length=10, num_walks=100, workers=1, verbose=0, stay_prob=0.3, opt1_reduce_len=True,
opt2_reduce_sim_calc=True, opt3_num_layers=None, temp_path='./temp_struc2vec/', reuse=False)
| 36 | |
| 37 | class Struc2Vec(): |
| 38 | def __init__(self, graph, walk_length=10, num_walks=100, workers=1, verbose=0, stay_prob=0.3, opt1_reduce_len=True, |
| 39 | opt2_reduce_sim_calc=True, opt3_num_layers=None, temp_path='./temp_struc2vec/', reuse=False): |
| 40 | self.graph = graph |
| 41 | self.idx2node, self.node2idx = preprocess_nxgraph(graph) |
| 42 | self.idx = list(range(len(self.idx2node))) |
| 43 | |
| 44 | self.opt1_reduce_len = opt1_reduce_len |
| 45 | self.opt2_reduce_sim_calc = opt2_reduce_sim_calc |
| 46 | self.opt3_num_layers = opt3_num_layers |
| 47 | |
| 48 | self.resue = reuse |
| 49 | self.temp_path = temp_path |
| 50 | |
| 51 | if not os.path.exists(self.temp_path): |
| 52 | os.mkdir(self.temp_path) |
| 53 | if not reuse: |
| 54 | shutil.rmtree(self.temp_path) |
| 55 | os.mkdir(self.temp_path) |
| 56 | |
| 57 | self.create_context_graph(self.opt3_num_layers, workers, verbose) |
| 58 | self.prepare_biased_walk() |
| 59 | self.walker = BiasedWalker(self.idx2node, self.temp_path) |
| 60 | self.sentences = self.walker.simulate_walks( |
| 61 | num_walks, walk_length, stay_prob, workers, verbose) |
| 62 | |
| 63 | self._embeddings = {} |
| 64 | |
| 65 | def create_context_graph(self, max_num_layers, workers=1, verbose=0, ): |
| 66 |
nothing calls this directly
no test coverage detected