(Solved) : Find Girth Undirected Graph Description Project Process Undirected Graph Necessarily Conne Q37202125 . . .
Find the Girth of an Undirected Graph
Description:
In this project, we will process an undirected graph, notnecessarily connected. The
girth of a graph is the length of a shortest cycle in this graph.After you nd the girth,
you also need to produce the cycle that corresponds to thegirth.
Requirements:
1. (Input) The input comes from a text le that stores the adjacencymatrix of a
graph. Your program will take the le name of an input as acommand-line argu-
ment. Then your program will read the content of the le line byline, in which
each row corresponds to one row of the adjacency matrix of agraph.
2. (Validation) Before we process the graph, we need to validatethe data to make
sure that the given data corresponds to the adjacency matrix of agraph. Basically
we need to check the following items:
(Square Matrix )
Each row of the data le has a sequence of integers separated by aspace char-
acter. Make sure that the number of rows equals the number ofcolumns.
Otherwise display an error message.
(Bit Value Entries)
Check if each entry of the matrix takes the bit value: 0 or 1. Ifnot, display an
error message.
(No Self-Loops)
Since an undirected graph cannot have any self-loop, we need tocheck that all
the diagonal entries must be 0. Otherwise display an errormessage.
(Valid Undirected Graph)
In order to make sure that this matrix corresponds to the adjacencymatrix of
an undirected graph, you need to check if it is symmetric. If not,display an
error message.
3. (Find the Girth) After you pass the data validation, you designan algorithm to
calculate its girth and its corresponding shortest cycle. In thisproject, the perfor-
mance of your algorithm is not very important, if only you get acorrect answer.
Hint
You can use the Breadth-First Search algorithm to calculate it. Youneed a way
to nd the length of the cycle. You may need to modify the originalBreadth-
First Search.
4. (Output) After you get the answer, you need to output the girthof the graph.
Other than that, you also need to print out this shortest cycle asa sequence of
vertex numbers.
5. (Testing) You need to prepare your own testing les for yourproject develop-
ment.
Expert Answer
Answer to Find the Girth of an Undirected Graph Description: In this project, we will process an undirected graph, not necessarily…
OR