Answered step by step
Verified Expert Solution
Link Copied!

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:
1. Read the number of nodes and edges (N and M) from outside.
2. Read the edge information as an adjacency list.
3. With the DFS approach, the shapes in your graph should be detected separately.
4. The nodes contained in the detected shape and the total perimeter length of the shape should be stored.
5. 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

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

Principles Of Database Systems With Internet And Java Applications

Authors: Greg Riccardi

1st Edition

020161247X, 978-0201612479

More Books

Students also viewed these Databases questions