Skip to main content

Graph Representation - Adjacency Matrix

Learn Graph Representation - Adjacency Matrix (Graphs, Advanced DSA) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Representing a Graph as a 2D Grid An adjacency matrix is a V × V array where matrix[i][j] = 1 (or a weight) means an edge exists from i to j. Checking "does an edge exist" is O(1); listing a vertex's neighbors is O(V) since the whole row must be scanned.

More lessons in Graphs