Question
Breadth First Search code using linked list based queue and vector. If you've already given a vector containing a couple of adjacency list type edges,
Breadth First Search code using linked list based queue and vector. If you've already given a vector containing a couple of adjacency list type edges, so basically if we have a vector { {1,2},{0,4},{0},{1} } and we always start at vertex 0.. so basically 0 is connected to 1 and 2..... then 1 is connected to 0 and 4.... then 2 is connected to 0... then 4 is connected to 1... if you make this into a graph, how would the breadth first search can help with finding the number of edges in order to reach from the starting vertex to the final vertex [ with consideration of it being the SHORTEST path possible]. So basically if we start the vertex as 0 then we want it to have an edge to value 1, the path length will be 1. If we start at vertex 0 and wanted to end at vertex 0 then the path length is 0. and so on.... if for instances there are a vertex 0 and we want it to have an edge to 6, but then to reach vertex 6 there are 3 ways to do so. The first way will have length of 4, the second way also have length of 4, but the third way will only have length of 1. So the path length from vertex 0 to vertex 6 has to be 1. How do to this?
Question:
1. How to make a linked list vector or anything that can help me make the graph from the given vectors containing the set of vertices (in adjacency list format)... basically how can I make the correlation of edges between vertices
2. How to find the shortest path possible and actually count the length?
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