Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

THIS IS GNU OCTAVE QUESTION 4. Write a function that takes an adjacency list representation of a graph as a cell array and returns its

THIS IS GNU OCTAVE QUESTION

image text in transcribed

4. Write a function that takes an adjacency list representation of a graph as a cell array and returns its edge-node listing representation as a matrix having two columns that holds edge information and a single number that gives the number of nodes. Example: Input cell array: {[2,4,5),(1,2,3,4),(2,4),(1,3,5,2),(4,5,1],[]} Output: N=6 12 14 15 22 23 24 314 4 15 55 Hints: Edges in the output matrix appears as unordered pairs. For example (1,2) and (2,1) represents the same edge. So it does not matter which one is used. While writing your function be careful that an edge will appear just once in the output edge matrix. For example, if a row contains (1,4), this should not appear again as neither (1,4) nor (4,1). Rows of the edge matrix do not have to be in the order shown in the example. As long as all edges are listed they can be shown in any order. For example, it would be fine if the edge matrix were given as follows. So feel free to create it any row order that you want. ALSO TEST YOUR FUNCTION WITH THE "Input cell array" above (the result should be the "Output" above) and take a screenshot of your OCTAVE, MATLAB or OCTAVE ONLINE screen and include it in your answer. NO SCREENSHOT = 0 marks for this

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_2

Step: 3

blur-text-image_3

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

Database Design And Implementation

Authors: Edward Sciore

2nd Edition

3030338355, 978-3030338350

More Books

Students also viewed these Databases questions

Question

What are the core functions of the universitys HRM department?

Answered: 1 week ago