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

Function test_edge_subgraph

tests/python/common/test_subgraph.py:35–54  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

33
34
35def test_edge_subgraph():
36 # Test when the graph has no node data and edge data.
37 g = generate_graph(add_data=False)
38 eid = [0, 2, 3, 6, 7, 9]
39
40 # relabel=True
41 sg = g.edge_subgraph(eid)
42 assert F.array_equal(
43 sg.ndata[dgl.NID], F.tensor([0, 2, 4, 5, 1, 9], g.idtype)
44 )
45 assert F.array_equal(sg.edata[dgl.EID], F.tensor(eid, g.idtype))
46 sg.ndata["h"] = F.arange(0, sg.num_nodes())
47 sg.edata["h"] = F.arange(0, sg.num_edges())
48
49 # relabel=False
50 sg = g.edge_subgraph(eid, relabel_nodes=False)
51 assert g.num_nodes() == sg.num_nodes()
52 assert F.array_equal(sg.edata[dgl.EID], F.tensor(eid, g.idtype))
53 sg.ndata["h"] = F.arange(0, sg.num_nodes())
54 sg.edata["h"] = F.arange(0, sg.num_edges())
55
56
57@pytest.mark.parametrize("relabel_nodes", [True, False])

Callers 1

test_subgraph.pyFile · 0.85

Calls 4

generate_graphFunction · 0.70
edge_subgraphMethod · 0.45
num_nodesMethod · 0.45
num_edgesMethod · 0.45

Tested by

no test coverage detected