Return a copy of this graph in shared memory, without node data or edge data. It moves the graph index to shared memory and returns a DGLGraph object which has the same graph structure, node types and edge types but does not contain node data or edge data. Parameter
(self, name, formats=("coo", "csr", "csc"))
| 6265 | |
| 6266 | # TODO: Formats should not be specified, just saving all the materialized formats |
| 6267 | def shared_memory(self, name, formats=("coo", "csr", "csc")): |
| 6268 | """Return a copy of this graph in shared memory, without node data or edge data. |
| 6269 | |
| 6270 | It moves the graph index to shared memory and returns a DGLGraph object which |
| 6271 | has the same graph structure, node types and edge types but does not contain node data |
| 6272 | or edge data. |
| 6273 | |
| 6274 | Parameters |
| 6275 | ---------- |
| 6276 | name : str |
| 6277 | The name of the shared memory. |
| 6278 | formats : str or a list of str (optional) |
| 6279 | Desired formats to be materialized. |
| 6280 | |
| 6281 | Returns |
| 6282 | ------- |
| 6283 | DGLGraph |
| 6284 | The graph in shared memory |
| 6285 | """ |
| 6286 | assert len(name) > 0, "The name of shared memory cannot be empty" |
| 6287 | assert len(formats) > 0 |
| 6288 | if isinstance(formats, str): |
| 6289 | formats = [formats] |
| 6290 | for fmt in formats: |
| 6291 | assert fmt in ( |
| 6292 | "coo", |
| 6293 | "csr", |
| 6294 | "csc", |
| 6295 | ), "{} is not coo, csr or csc".format(fmt) |
| 6296 | gidx = self._graph.shared_memory( |
| 6297 | name, self.ntypes, self.etypes, formats |
| 6298 | ) |
| 6299 | return DGLGraph(gidx, self.ntypes, self.etypes) |
| 6300 | |
| 6301 | def long(self): |
| 6302 | """Cast the graph to one with idtype int64 |