Grokking Data Structures & Algorithms for Coding Interviews
Vote

0% completed

Graph Representations

Graphs can be represented in multiple ways depending on the use case. The three you will meet most often are:

  • Adjacency Matrix
  • Adjacency List
  • Edge List

Let's break down each approach with examples for undirected and directed graphs.

1 Adjacency Matrix

An adjacency matrix is a 2D array (or matrix) used to represent the presence or absence of edges between vertices.

  • The matrix is of size N × N, where N is the number of vertices.
  • Each cell (i, j) indicates whether there's an edge from vertex i to vertex j.

.....

.....

.....

Like the course? Get enrolled and start learning!
Chaithra Nayak

Chaithra Nayak

· 10 months ago

As a result, the adjacency list for an undirected graph is symmetric.

How is the adjacency list symmetric? Does it not apply to only adjacency matrix?

Show 1 reply

Reading Progress

0%


Vote for new content