Question
c++ graph This is what I need: 1. Make a function to get numOfTheShortestPaths function. 2. I already have a working code for thePathLen function,
c++ graph
This is what I need:
1. Make a function to get numOfTheShortestPaths function.
2. I already have a working code for thePathLen function, and got the vectors already. I just need to do the numOfTheShortestPaths part. This is basically asking me to get how many walks is possible from the source (which will always be 0) to the destination with a fixed path length.
3. I will be using linked based queue for storing the adjacency list.
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 & thePathLen, 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
//I need to make a function to get expectedOfNumberShortestPath
EXPECT_TRUE(thePathLen ==expectedOfThePathLen && expectedOfNumberShortestPath ==numOfTheShortestPaths);
}
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