Answered step by step
Verified Expert Solution
Question
1 Approved Answer
An undirected weighted graph with N nodes and M edges is given as an adjacency list. You are expected to design an algorithm that finds
An undirected weighted graph with N nodes and M edges is given as an adjacency list. You are expected to design an algorithm that finds the polygons triangles quadrilaterals, pentagons, hexagons, etc. formed by the links in this graph and prints the nodes and the perimeter lengths of each of the shapes. The algorithm you design should print the total number of shapes, the number of individual shapes, their nodes, and their perimeter lengths.
The steps to be implemented in your program are as follows:
Read the number of nodes and edges N and M from outside.
Read the edge information as an adjacency list.
With the DFS approach, the shapes in your graph should be detected separately.
The nodes contained in the detected shape and the total perimeter length of the shape should be stored.
Finally, the total number of shapes, the type of polygons triangle quadrilateral, etc. their number, the nodes they contain and their perimeter length should be printed on the screen.
Note: The same shape should not be added to the list for different starting points. Use the edge weights to calculate the perimeter lengths. This code is required in C language.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started