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

Function generate_graph

tests/python/common/test_subgraph.py:15–32  ·  view source on GitHub ↗
(grad=False, add_data=True)

Source from the content-addressed store, hash-verified

13
14
15def generate_graph(grad=False, add_data=True):
16 g = dgl.graph([]).to(F.ctx())
17 g.add_nodes(10)
18 # create a graph where 0 is the source and 9 is the sink
19 for i in range(1, 9):
20 g.add_edges(0, i)
21 g.add_edges(i, 9)
22 # add a back flow from 9 to 0
23 g.add_edges(9, 0)
24 if add_data:
25 ncol = F.randn((10, D))
26 ecol = F.randn((17, D))
27 if grad:
28 ncol = F.attach_grad(ncol)
29 ecol = F.attach_grad(ecol)
30 g.ndata["h"] = ncol
31 g.edata["l"] = ecol
32 return g
33
34
35def test_edge_subgraph():

Callers 2

test_edge_subgraphFunction · 0.70

Calls 5

toMethod · 0.45
graphMethod · 0.45
ctxMethod · 0.45
add_nodesMethod · 0.45
add_edgesMethod · 0.45

Tested by

no test coverage detected