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):

Invest in Yourself
Your new job is waiting. 83% of people that complete the program get a job offer. Unlock unlimited access to all content and features.
Go Pro