• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 9 pages
Class notes

Graphs in Data Structures – Adjacency Matrix, Adjacency List, BFS & DFS Complete Notes

Document preview thumbnail
Preview 2 out of 9 pages

Complete and well-organized Data Structures – Graphs notes covering important graph concepts, representations, and traversal techniques. These notes explain the topic in a simple and easy-to-understand format, making them useful for exam preparation, assignments, revision, and viva preparation. Topics Covered: Graph Basics & Terminology Adjacency Matrix Representation Adjacency List Representation Breadth First Search (BFS) Depth First Search (DFS) BFS vs DFS Comparison Graph Representation Comparison Real-Life Applications of Graphs Important Viva Questions Ideal study material for Computer Science, DSA, and programming students looking for clear and structured Graphs notes.

Content preview

Data Structures — Graphs BFS | DFS | Adjacency Matrix | Adjacency List




Data Structures
Chapter: Graphs
Adjacency Matrix | Adjacency List | BFS | DFS


Topics Covered
• Graph Basics & Terminology
• Adjacency Matrix Representation
• Adjacency List Representation
• BFS Traversal Algorithm
• DFS Traversal Algorithm
• Comparison Tables
• Real Life Applications
• Viva Questions




1. Introduction to Graphs
Graphs are one of the most important non-linear data structures in Computer Science. They
are used to represent relationships between objects. Unlike arrays, linked lists, stacks, and
queues which store data linearly, graphs represent complex connections among multiple
entities.


1.1 Real-World Applications
• Social Networks (Facebook friends, Instagram followers)
• Google Maps and Navigation Systems
• Computer Networks
• Airline Route Systems
• Web Page Linking
• Artificial Intelligence
• Operating Systems
• Compiler Design


Mathematical Definition: G = (V, E) where G = Graph, V = Set of Vertices, E = Set of
Edges




CS Notes Page 1

, Data Structures — Graphs BFS | DFS | Adjacency Matrix | Adjacency List



2. Basic Terminology
2.1 Vertex (Node)
A vertex is an individual point in a graph. Example: Cities like Lahore, Karachi, Islamabad.

2.2 Edge
An edge is a connection between two vertices.

Example: E = (Lahore, Karachi)


2.3 Directed Graph (Digraph)
Edges have direction. Example: A follows B on Twitter does not mean B follows A.

Representation: A → B


2.4 Undirected Graph
Edges do not have direction. If A is connected to B, then B is automatically connected to A.

Representation: A — B


2.5 Weighted Graph
A graph in which edges contain weights or costs.

Example: Lahore → Karachi = 1200 km


2.6 Degree of Vertex
The number of edges connected to a vertex is called its degree.

Formula: Degree(A) = 3 (if 3 edges are connected)


2.7 Path
A sequence of vertices connected through edges.

Example: A → B → C → D


2.8 Cycle
A path that starts and ends at the same vertex.

Example: A → B → C → A




CS Notes Page 2

Document information

Uploaded on
October 3, 2026
Number of pages
9
Written in
2026/2027
Type
Class notes
Professor(s)
Sir zain
Contains
All classes
$3.49

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Sold
0
Followers
0
Items
43
Last sold
-



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions