Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ADJACENCY LIST ( use Breadth-First Search algorithm) How to get the total number of paths of fixed length from vector of vector adjacency LIST. REMEMBER:

ADJACENCY LIST ( use Breadth-First Search algorithm)

How to get the total number of paths of fixed length from vector of vector adjacency LIST. REMEMBER: the fixed length has to be the shortest length.

So, const std::vector< std::vector<unsigned> > & adjList;

and I'm supposed to get the number of paths for a given shortest path from the adjList.

What I want:

1. To define the function countingGraphPathWays(const vector< vector > &adjVertex, unsigned source, vector & thPathLen, vector & numOfTheShortestPaths)

2. For the TESTED CODE to run (see attached code below) (this tested code help defining the function countingGraphPathWays)

THIS IS THE TESTED CODE (the bold are the code, and the italicswords are the information of what each function does):

TRY(GraphingTester, GraphingTesterA) { vector< vector > gA = { {1, 2, 4}, {0,3}, {0,3}, {1,2,5, 7}, {0, 5, 6}, {3, 4}, {4, 7}, {3, 6}, }; //adjacency list

vector pathLengths(8);

vector numShortestPaths(8); countingGraphPathWays(gA, 0,thePathLen, numOfTheShortestPaths);

/**

The function: countingGraphPathWays(const vector< vector > &adjVertex, unsigned source, vector & thPathLen, vector & numOfTheShortestPaths)

**/

//thePathLen = path lengths is basically the shortest length to reach from the source vertex to the destination vertex

vector expectedOfThePathLen = {0, 1, 1, 2, 1, 2, 2, 3}; //source vertex is 0 , and this is shortest length vector expectedOfNumberShortestPath = {1, 1, 1, 2, 1, 1, 1, 3}; //source vertex is 0, how many ways to get to shortest length

EXPECT_TRUE(thePathLen ==expectedOfThePathLen && expectedOfNumberShortestPath ==numOfTheShortestPaths);

}

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

SQL Server Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

More Books

Students also viewed these Databases questions

Question

5.3 Explain internal recruitment methods.

Answered: 1 week ago

Question

5. Our efficiency focus eliminates free time for fresh thinking.

Answered: 1 week ago