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

Function main

examples/node2vec_flight.py:50–76  ·  view source on GitHub ↗
(smoke=False, show=True)

Source from the content-addressed store, hash-verified

48
49
50def main(smoke=False, show=True):
51 graph_path = SMOKE_GRAPH_PATH if smoke else FLIGHT_GRAPH_PATH
52 graph = nx.read_edgelist(
53 str(graph_path),
54 create_using=nx.DiGraph(),
55 nodetype=None,
56 data=[("weight", int)],
57 )
58
59 model = Node2Vec(
60 graph,
61 walk_length=3 if smoke else 10,
62 num_walks=2 if smoke else 80,
63 workers=1,
64 p=0.25,
65 q=2,
66 use_rejection_sampling=False,
67 )
68 model.train(window_size=2 if smoke else 5, iter=1 if smoke else 3, workers=1)
69 embeddings = model.get_embeddings()
70 assert len(embeddings) > 0
71
72 if not smoke:
73 evaluate_embeddings(embeddings, FLIGHT_LABEL_PATH)
74 plot_embeddings(embeddings, FLIGHT_LABEL_PATH, show=show)
75
76 return embeddings
77
78
79if __name__ == "__main__":

Callers 1

node2vec_flight.pyFile · 0.70

Calls 5

trainMethod · 0.95
get_embeddingsMethod · 0.95
Node2VecClass · 0.90
evaluate_embeddingsFunction · 0.70
plot_embeddingsFunction · 0.70

Tested by

no test coverage detected