MCPcopy
hub / github.com/shenweichen/GraphEmbedding / __init__

Method __init__

ge/models/struc2vec.py:38–63  ·  view source on GitHub ↗
(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)

Source from the content-addressed store, hash-verified

36
37class 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

Callers

nothing calls this directly

Calls 5

create_context_graphMethod · 0.95
prepare_biased_walkMethod · 0.95
preprocess_nxgraphFunction · 0.85
BiasedWalkerClass · 0.85
simulate_walksMethod · 0.45

Tested by

no test coverage detected