What is an adjacency matrix?

Dijkstra Algorithm Questions



80 Short 62 Medium 80 Long Answer Questions Question Index

What is an adjacency matrix?

An adjacency matrix is a square matrix used to represent a graph. It is a 2-dimensional array where the rows and columns represent the vertices of the graph. The value in each cell of the matrix indicates whether there is an edge between the corresponding vertices. If there is an edge, the value is typically 1 or a weight associated with the edge, and if there is no edge, the value is usually 0 or infinity. The adjacency matrix is symmetric for an undirected graph, while for a directed graph, it may not be symmetric.