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)
| 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. |
no outgoing calls