Matrix, Graph, Data Science, Artificial Intelligence, Linear Algebra.
up either the upper or lower triangle of the matrix. If the graph is directed, then summing the matrix tells us the total number of edges: np.triu(adj_mat).sum() # evalutes to 4.0 Additionally, taking the k-th matrix powers of the adjacency matrix tells us the number of ways to reach another node