dgl.khop_adj(g, k)[source]

Return the matrix of $$A^k$$ where $$A$$ is the adjacency matrix of the graph $$g$$.

The returned matrix is a 32-bit float dense matrix on CPU. The graph must be homogeneous.

Parameters
• g (DGLGraph) – The input graph.

• k (int) – The $$k$$ in $$A^k$$.

Returns

The returned tensor.

Return type

Tensor

Examples

>>> import dgl
>>> g = dgl.graph(([0,1,2,3,4,0,1,2,3,4], [0,1,2,3,4,1,2,3,4,0]))