MCPcopy
hub / github.com/dmlc/dgl / test_from_cugraph_conversion

Function test_from_cugraph_conversion

tests/cugraph/test_basics.py:26–64  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

24
25
26def test_from_cugraph_conversion():
27 # cudf is a dependency of cugraph
28 import cudf
29
30 # directed graph conversion test
31 cugraph_g = cugraph.Graph(directed=True)
32 df = cudf.DataFrame({"source": [0, 1, 2, 3], "destination": [1, 2, 3, 2]})
33
34 cugraph_g.from_cudf_edgelist(df)
35
36 g = dgl.from_cugraph(cugraph_g)
37
38 assert g.device.type == "cuda"
39 assert g.num_nodes() == cugraph_g.number_of_nodes()
40 assert g.num_edges() == cugraph_g.number_of_edges()
41
42 # assert reverse edges are not present
43 assert g.has_edges_between(0, 1)
44 assert not g.has_edges_between(1, 0)
45 assert g.has_edges_between(1, 2)
46 assert not g.has_edges_between(2, 1)
47 assert g.has_edges_between(2, 3)
48
49 # undirected graph conversion test
50 cugraph_g = cugraph.Graph(directed=False)
51 df = cudf.DataFrame({"source": [0, 1, 2, 3], "destination": [1, 2, 3, 2]})
52
53 cugraph_g.from_cudf_edgelist(df)
54
55 g = dgl.from_cugraph(cugraph_g)
56
57 assert g.device.type == "cuda"
58 assert g.num_nodes() == cugraph_g.number_of_nodes()
59 # assert reverse edges are present
60 assert g.has_edges_between(0, 1)
61 assert g.has_edges_between(1, 0)
62 assert g.has_edges_between(1, 2)
63 assert g.has_edges_between(2, 1)
64 assert g.has_edges_between(2, 3)

Callers

nothing calls this directly

Calls 5

num_nodesMethod · 0.45
number_of_nodesMethod · 0.45
num_edgesMethod · 0.45
number_of_edgesMethod · 0.45
has_edges_betweenMethod · 0.45

Tested by

no test coverage detected