Question: Data Structure in C++ Graphs and Breadth-first Search Adj. list graphs Write an implementation of the adjacency listgraph representation. You may assume that nodes are
Data Structure in C++
Graphs and Breadth-first Search

Adj. list graphs Write an implementation of the adjacency listgraph representation. You may assume that nodes are integers which start at 0. Using your implementation, implement the breadth-first-search algorithm, as a function which takes a graph a starting node and a target node, and searches for a path between them. Your BFS function should return the shortest distance from the source node to the target node, or -1 if no path exists. Commands Implement the following commands Command Description create nr Create a new empty graph in register r, with n nodes print r Print some representation of the graph in r arc a b r in the graph in register r, create an arc from node a to b biarc a b r Create a bidirectional arc from a to b in r bfs a b r Perform a breadth-first search from a to b in r, printing the distance Write the register commands necessary to create the following graph: and place them in a comment in your source code. What is the distance from node 9 to node 6
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
