dgl.DGLGraph.adjacency_matrix

DGLGraph.adjacency_matrix(transpose=False, ctx=device(type='cpu'))[source]

Return the adjacency matrix representation of this graph.

By default, a row of returned adjacency matrix represents the destination of an edge and the column represents the source.

When transpose is True, a row represents the source and a column represents a destination.

Parameters:
  • transpose (bool, optional (default=False)) – A flag to transpose the returned adjacency matrix.
  • ctx (context, optional (default=cpu)) – The context of returned adjacency matrix.
Returns:

The adjacency matrix.

Return type:

SparseTensor