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

Method create_formats_

python/dgl/heterograph.py:6201–6239  ·  view source on GitHub ↗

r"""Create all sparse matrices allowed for the graph. By default, we create sparse matrices for a graph only when necessary. In some cases we may want to create them immediately (e.g. in a multi-process data loader), which can be achieved via this API. Examples

(self)

Source from the content-addressed store, hash-verified

6199 return ret
6200
6201 def create_formats_(self):
6202 r"""Create all sparse matrices allowed for the graph.
6203
6204 By default, we create sparse matrices for a graph only when necessary.
6205 In some cases we may want to create them immediately (e.g. in a
6206 multi-process data loader), which can be achieved via this API.
6207
6208 Examples
6209 --------
6210
6211 The following example uses PyTorch backend.
6212
6213 >>> import dgl
6214 >>> import torch
6215
6216 **Homographs or Heterographs with A Single Edge Type**
6217
6218 >>> g = dgl.graph(([0, 0, 1], [2, 3, 2]))
6219 >>> g.format()
6220 {'created': ['coo'], 'not created': ['csr', 'csc']}
6221 >>> g.create_formats_()
6222 >>> g.format()
6223 {'created': ['coo', 'csr', 'csc'], 'not created': []}
6224
6225 **Heterographs with Multiple Edge Types**
6226
6227 >>> g = dgl.heterograph({
6228 ... ('user', 'plays', 'game'): (torch.tensor([0, 1, 1, 2]),
6229 ... torch.tensor([0, 0, 1, 1])),
6230 ... ('developer', 'develops', 'game'): (torch.tensor([0, 1]),
6231 ... torch.tensor([0, 1]))
6232 ... })
6233 >>> g.format()
6234 {'created': ['coo'], 'not created': ['csr', 'csc']}
6235 >>> g.create_formats_()
6236 >>> g.format()
6237 {'created': ['coo', 'csr', 'csc'], 'not created': []}
6238 """
6239 return self._graph.create_formats_()
6240
6241 def astype(self, idtype):
6242 """Cast this graph to use another ID type.

Callers 15

__init__Method · 0.45
_format_partitionFunction · 0.45
test_subframesFunction · 0.45
test_uva_subgraphFunction · 0.45
test_formatFunction · 0.45
test_forking_picklerFunction · 0.45
test_formatsFunction · 0.45
test_uniform_random_walkFunction · 0.45
test_pinsage_samplingFunction · 0.45

Calls

no outgoing calls

Tested by 11

test_subframesFunction · 0.36
test_uva_subgraphFunction · 0.36
test_formatFunction · 0.36
test_forking_picklerFunction · 0.36
test_formatsFunction · 0.36
test_uniform_random_walkFunction · 0.36
test_pinsage_samplingFunction · 0.36