adjacentiematrix
An adjacency matrix is a way to represent a graph as a square matrix. Given a graph G with n vertices V = {v1, v2, ..., vn}, its adjacency matrix A is an n-by-n matrix where the entry Aij indicates the presence and often the weight or multiplicity of the edge from vertex vi to vertex vj. In simple, unweighted graphs, Aij is 1 if there is an edge from vi to vj and 0 otherwise; typically Aii is 0 unless loops are allowed.
Different graph types yield different matrix patterns. For undirected graphs without loops, the adjacency matrix is
Key properties and uses. The sum of the ith row equals the degree of vertex vi in
Computational considerations. Storing an adjacency matrix requires O(n^2) space, which can be inefficient for large, sparse