hiperwalk.Graph.adjacency_matrix#

Graph.adjacency_matrix()[source]#

Return the adjacency matrix representation of the graph.

Return a hard copy of the adjacency matrix.

Returns:
scipy.sparse.csr_array.

Notes

In a simple graph \(G(V, E)\) with \(n\) vertices \(v_0, \ldots, v_{n-1}\), the adjacency matrix of \(G(V, E)\) is an \(n\)-dimensional matrix \(A\), defined as follows:

\[\begin{split}A_{i,j} = \begin{cases} 1, & \text{if } v_i \text{ is adjacent to } v_j,\\ 0, & \text{otherwise.} \end{cases}\end{split}\]

If \(G(V, E)\) has a loop on vertex \(v_i\), then \(A_{i,i}=1\).

In multigraphs, where multiple edges can exist between the same pair of vertices, the adjacency matrix reflects this by counting the number of such edges.