MCPcopy Index your code
hub / github.com/shenweichen/GraphEmbedding / test_Struc2Vec

Function test_Struc2Vec

tests/struct2vec_test.py:15–35  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13
14
15def test_Struc2Vec():
16 graph = nx.read_edgelist(
17 str(TEST_GRAPH_PATH),
18 create_using=nx.DiGraph(),
19 nodetype=None,
20 data=[("weight", int)],
21 )
22
23 with tempfile.TemporaryDirectory(prefix="struc2vec-test-") as temp_dir:
24 model = Struc2Vec(
25 graph,
26 walk_length=3,
27 num_walks=1,
28 workers=1,
29 verbose=0,
30 temp_path=temp_dir + "/",
31 )
32 model.train(embed_size=8, window_size=2, workers=1, iter=1)
33 embeddings = model.get_embeddings()
34 assert len(embeddings) == graph.number_of_nodes()
35 assert all(len(vector) == 8 for vector in embeddings.values())
36
37
38if __name__ == "__main__":

Callers

nothing calls this directly

Calls 3

trainMethod · 0.95
get_embeddingsMethod · 0.95
Struc2VecClass · 0.90

Tested by

no test coverage detected