dgl.DGLHeteroGraph.format_in_use

DGLHeteroGraph.format_in_use(etype=None)[source]

Return the sparse formats in use of the given edge/relation type.

Parameters:etype (str or tuple of str, optional) – The edge type. Can be omitted if there is only one edge type in the graph.
Returns:Return all the formats currently in use (could be multiple).
Return type:list of str

Examples

For graph with only one edge type.

>>> g = dgl.graph(([0, 1], [1, 2]), 'user', 'follows', restrict_format='csr')
>>> g.format_in_use()
['csr']

For a graph with multiple types.

>>> g = dgl.heterograph({
...     ('user', 'plays', 'game'): ([0, 1, 1, 2], [0, 0, 1, 1]),
...     ('developer', 'develops', 'game'): ([0, 1], [0, 1]),
...     }, restrict_format='any')
>>> g.format_in_use('develops')
['coo']
>>> spmat = g['develops'].adjacency_matrix(
...     transpose=True, scipy_fmt='csr')    // Create CSR representation.
>>> g.format_in_use('develops')
['coo', 'csr']

which is equivalent to:

>>> g['develops'].restrict_format()
['coo', 'csr']

See also

restrict_format(), request_format(), to_format()