Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

need help with Breadth for Search c++ 1.First of all is using adjacency list, basically using #include , is basically a standard library ? 2.

need help with Breadth for Search c++

1.First of all is using adjacency list, basically using #include , is basically a standard library ?

2. Help me with an algorithm/pseudocode/a simple code(most preferred) on how to get the NUMBER OF ALL PATHS WITH GIVEN LENGTH, N, in a given UNDIRECTED & UNWEIGHTED graph. The vertices are stored in adjacency list format... So how would I can et all the number of path of fixed length from one vertices to another vertices, AND THESE PATH LENGTHS ARE THE SHORTEST LENGTH TO GET FROM ONE VERTICES TO THE OTHER.

So let's say from 0 vertices to 5 vertices, there are 4 ways to do this. The first way require a path length of 4, the second way requires a path length of 5, third way requires a path length of only 1, and the fourth way also requires only path length of 1.. So now I want to get the number of paths of a given SHORTEST path length,n. So basically n is equals to 1, because that's the shortest paths to get from vertices 0 to vertices 5. Then, the answer/result for the number of paths of a given SHORTEST path length,n - where n is equals to 1-, will be 2 (since there's two ways for the vertices 0 to reach vertices 5 with path length of 1). So now please give a clear explanation of what to do (please use visualization drawings as necessary as this help me to understand better).

REMEMBER: this is in the form of adjacency list! and it is an UNDIRECTED and UNWEIGHTED graph.

Example test cases that has to be pass (in which I have to make the function definition for countingGraphPathWays ):

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

std::vector pathLengths(8); std::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

std::vector expectedOfThePathLen = {0, 1, 1, 2, 1, 2, 2, 3}; //source vertex is 0 , and this is shortest length std::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

Real Time Database And Information Systems Research Advances

Authors: Azer Bestavros ,Victor Fay-Wolfe

1st Edition

1461377803, 978-1461377801

More Books

Students also viewed these Databases questions

Question

Question In Chemical Engineering, Don't Give AI Answer 1 5 1 .

Answered: 1 week ago

Question

an element of formality in the workplace between different levels;

Answered: 1 week ago