Represent Directed Graph with Matrix
$n \times n $ matrix $\mathbf{A}$ represents directed graph
\[ \mathbf{A}_{i,j} = \begin{cases} 1, & \text{ there is vertex i to vertex j} \\ 0, & \text{otherwise} \end{cases} \\ A = \begin{bmatrix} 0 & 1 & 0 & 1 & 0 \\ 1 & 0 & 0 & 0 & 0 \\ 0 & 1 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 & 1 \\ 1 & 0 & 1 & 0 & 0 \end{bmatrix} \]

Path in Directed Graph
\[ \mathbf(A)^{2}_{i,j} = \sum_{k=1}^{n} \mathbf{A}_{i,k}\mathbf{A}_{k,j} \quad \text{number of paths from vertex i to vertex j} \\ A^2 = \begin{bmatrix} 1 & 0 & 1 & 0 & 1 \\ 0 & 1 & 0 & 1 & 0 \\ 1 & 1 & 1 & 0 & 0 \\ 1 & 1 & 2 & 0 & 0 \\ 0 & 2 & 1 & 1 & 0 \\ \end{bmatrix} \\ \text{Two path from vertex 5 to vertex 1} \\ \text{Two path from vertex 4 to vertex 3} \\ A^3 = \begin{bmatrix} 1 & 2 & 2 & 1 & 0 \\ 1 & 0 & 1 & 0 & 1 \\ 1 & 2 & 1 & 1 & 0 \\ 1 & 3 & 2 & 1 & 0 \\ 2 & 1 & 2 & 0 & 1 \\ \end{bmatrix} \\ \text{Three path from vertex 4 to vertex 2} \\ \]