MCPcopy Create free account
hub / github.com/easy-graph/Easy-Graph / simulate_walks

Function simulate_walks

easygraph/functions/graph_embedding/node2vec.py:149–166  ·  view source on GitHub ↗
(G, walk_length, num_walks, p, q, weight_key=None)

Source from the content-addressed store, hash-verified

147
148
149def simulate_walks(G, walk_length, num_walks, p, q, weight_key=None):
150 alias_nodes, alias_edges = _preprocess_transition_probs(G, p, q, weight_key)
151 walks = []
152 nodes = list(G.nodes)
153 for walk_iter in tqdm(range(num_walks)):
154 random.shuffle(nodes)
155 for node in nodes:
156 walks.append(
157 _node2vec_walk(
158 G,
159 walk_length=walk_length,
160 start_node=node,
161 alias_nodes=alias_nodes,
162 alias_edges=alias_edges,
163 )
164 )
165
166 return walks
167
168
169def _preprocess_transition_probs(G, p, q, weight_key=None):

Callers 1

node2vecFunction · 0.70

Calls 3

_node2vec_walkFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected