An adjacency matrix is a square grid used to represent a graph, where each row and column corresponds to a vertex. The entries in the matrix indicate whether pairs of vertices are connected by an edge. If there is an edge between two vertices, the corresponding entry is marked with a 1; if not, it is marked with a 0. This representation is particularly useful for analyzing the structure of graphs in computer science and mathematics.
Adjacency matrices can be applied to both directed and undirected graphs. In a directed graph, the matrix is not necessarily symmetric, as edges have a direction. For example, if there is an edge from vertex A to vertex B, the entry for A to B will be 1, while the entry for B to A may be 0. This matrix format simplifies various graph algorithms, such as finding paths or determining connectivity.