Matrix as Graph

Prereq: BFS on Graph

Very often, graph problems are represented as matrices. For example:

In most matrix graph problems, the statement will mention adjacent cells being connected.

A matrix translates to a graph (adjacency list):


🪄