Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Graph Representations

We primarily represent graphs using two ways:

  1. Adjacency matrix
  2. Adjacency list

Let's explore what they are.

Adjacency Matrix

An adjacency matrix is a common way to represent a graph as a matrix. It is a square matrix where the rows and columns represent the vertices of the graph, and the entries (elements) of the matrix indicate whether there is an edge between the corresponding vertices.

In an undirected graph, the edges have no direction, meaning they can be traversed in both directions between two vertices




Like the course? Get enrolled and start learning!