Question: 1. Write an algorithm to test whether a given graph is connected or not.
Connected
Components
Definition :
In undirected graph, two vertices are connected if they have a path connecting
them.

The
connected components of graph G are

•
In order to determine whether or not the graph is connected the DFS is called.
The algorithm to find whether or not the graph is connected is as shown below.
connected_ Comp (G, n)
{
// Problem Description: This algorithm determines
// The connected components of graph
// Input: Graph G represented using adjacency
// matrix
// Output: Prints connected components of G
// visited [ ] is an array that keeps track
//of visited vertices from G.
for i = 1 to n do
visited [i] = 0; //
initialize
for i = 1 to n do
if (visited [i] = 0)
Dfs (i);
}
•
Thus connected components of graph are those components in which there is a
path between every pair of vertices. Finding the connected components of graph
is one of the applications of graph.
1. Write an algorithm
to test whether a given graph is connected or not.
Data Structures using C PlusPlus: Chapter 7: Graphs : Tag: Data Structure, C++ Programing : Data Structures using C++ Program - Graphs: Connected Components
Data Structures using CPlusPlus
CS25C05 2nd Semester ECE Dept | 2025 Regulation | 2nd Semester 2025 Regulation
English Essentials II
EN25C02 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation
Tamils and Technology தமிழர்களும் தொழில்நுட்பமும்
UC25H02 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation
Linear Algebra
MA25C02 2nd Semester | 2025 Regulation
Electron Devices
EC25C01 2nd Semester ECE Dept | 2025 Regulation | 2nd Semester 2025 Regulation
Data Structures using CPlusPlus
CS25C05 2nd Semester ECE Dept | 2025 Regulation | 2nd Semester 2025 Regulation
Circuits and Network Analysis
EC25C02 2nd Semester ECE Dept | 2025 Regulation | 2nd Semester 2025 Regulation
Re-Engineering for Innovation
ME25C05 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation
Engineering Drawing - Laboratory
ME25C01 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation
Data Structures using CPlusPlus - Laboratory
CS25C05 2nd Semester ECE Dept | 2025 Regulation | 2nd Semester 2025 Regulation
Devices and Circuits Laboratory
EC25C03 2nd Semester ECE Dept | 2025 Regulation | 2nd Semester 2025 Regulation