Adjacency Matrix Representation

Introduction

A graph is just a set of vertices and the edges that connect them, but before you can write code that works on a graph you have to decide how to store it. The adjacency matrix is the most direct answer: number the vertices 0 through n-1, then build an n-by-n table where the entry in row i and column j records whether an edge runs from vertex i to vertex j. For an unweighted graph the entries are typically 1 and 0; for a weighted graph they can hold the edge weight instead.

This representation matters in COP3530 because it is one half of the central design trade-off you will be asked to reason about all module long. A matrix always occupies space proportional to the square of the vertex count, regardless of how few edges exist, but it answers the question "is there an edge between u and v?" in constant time. The adjacency list flips both of those properties. Knowing which one to reach for depends on whether your graph is dense or sparse, and on which operations your algorithm performs most often.

As you watch, pay attention to a few specific things. First, notice how symmetry across the main diagonal signals an undirected graph, and how a directed graph's matrix is generally asymmetric. Second, track the complexity claims carefully: space, edge lookup, adding or removing an edge, and iterating over all neighbors of a vertex are each different costs. Third, watch for how the presenters handle weighted edges and self-loops, since those details often show up in assignments.

Video 1: 0406: Adjacency-matrix representation

cs128 · 10:10 · 4,539 views · 5y ago · captions — Watch on YouTube

About this video

A focused lecture segment devoted entirely to the adjacency matrix representation of a graph G with a given vertex set and edge set. Given its short length and narrow title, it most likely walks through the formal definition of the matrix, how entries are filled in from the edge set, and the storage and lookup costs that follow. Expect a definition-first, notation-heavy treatment rather than code.

Why this video

This is the most tightly scoped video of the three, so it is a good first stop for the "What Is an Adjacency Matrix?" and space complexity subtopics before you move on to comparisons and implementations.

Video 2: Graph Data Structure | Adjacency Matrix and Adjacency List Graph | Graph DSA Java C++ | DSAOne #74

Anuj Kumar Sharma · 12:16 · 137,080 views · 4y ago · captions — Watch on YouTube

About this video

Part of the DSAOne series, this video covers implementing graphs in code using both the adjacency matrix and the adjacency list, with Java and C++ mentioned in the title. It should show the actual two-dimensional array setup for a matrix alongside the list-of-neighbors alternative, so you can see the two data layouts side by side. The comparison framing means the trade-offs between the two should come up directly.

Why this video

The side-by-side treatment maps straight onto the advantages, trade-offs and limitations subtopics, and seeing concrete code makes the abstract space and time claims much easier to believe and remember.

Video 3: 4.2 : Representing Graphs

IIT Madras - B.S. Degree Programme · 18:05 · 23,753 views · 5y ago · captions — Watch on YouTube

About this video

A university lecture from IIT Madras on representing graphs, delivered as part of a programming and algorithms course taught by Prof. Madhavan. At eighteen minutes it is the longest of the three and should cover the representation question broadly, including matrices, lists, and the complexity reasoning behind choosing between them. Directed and undirected cases are a standard part of such a lecture.

Why this video

The longer format and academic source give you the most careful treatment of complexity analysis and of how directed versus undirected graphs change the matrix, which is exactly the reasoning the module asks you to reproduce.

How These Videos Support the Learning Outcomes

Together these videos build the representation knowledge the module depends on. The directed versus undirected discussion, and the matrix symmetry that distinguishes them, supports MO1 by giving you a concrete way to tell the two graph types apart. The heart of the alignment is MO2: all three videos address how much space a matrix consumes and how fast its common operations run, and the DSAOne and IIT Madras videos set those figures directly against the adjacency list so you can argue which representation suits a sparse or a dense graph. Because MO4 asks you to build a Graph class on adjacency list storage, understanding why the matrix is the wrong choice for that assignment is part of the preparation, and the code-level videos here make that contrast tangible before you move on to the traversal outcomes in MO3 and MO5.

About These Videos

These videos were chosen from YouTube on October 2, 2026. Each has captions; the player turns them on. Videos on YouTube can be changed or removed — if one no longer plays, tell your instructor. If a player does not appear, use its Watch on YouTube link.