Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C + + program that inputs a graph and execute the following function: a ) Use Depth First Search to find the number

Write a C++ program that inputs a graph and execute the following function:
a) Use Depth First Search to find the number of connected components
and at least a cycle (the graph must contain at least a cycle) of the graphs
shown below. Display the edges of the cycles, for example in graph one
below, the following edges should be displayed "Cycle: (0,1),(1,2),(2,3),
(3,0)".
In order to accomplish this task, you must declare a class Graph as defined in
class and implement a function Creates () th at creates the link-list of the graph
(see lectures notes). Also the nodes must be labeled from 0 to n-1(n is the
number of nodes). In the class function Creates, a pair of nodes is input
(example: 0,1- representing the edge (0,1)).
It is recommended to implement the function Creates first.
Must try the following graphs as inputs (other graphs won't be accepted)
(2)
Write a C++ program that inputs a graph and execute the following function:
a) Use Depth First Search to find the number of connected components and at least a cycle (the graph must contain at least a cycle) of the graphs shown below. Display the edges of the cycles, for example in graph one below, the following edges should be displayed Cycle: (0,1),(1,2),(2,3),(3,0).
In order to accomplish this task, you must declare a class Graph as defined in class and implement a function Creates () that creates the link-list of the graph (see lectures notes). Also the nodes must be labeled from 0 to n-1(n is the number of nodes). In the class function Creates, a pair of nodes is input (example: 0,1- representing the edge (0,1)).
It is recommended to implement the function Creates first.
Must try the following graphs as inputs (other graphs wont be accepted)
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Analysis Using SQL And Excel

Authors: Gordon S Linoff

2nd Edition

111902143X, 9781119021438

More Books

Students also viewed these Databases questions