Question: Do this in C++ Construct an adjacency-list implementation of a directed, unweighted graph, and then use it to implement the breadth-first algorithms . Write an
Do this in C++
Construct an adjacency-list implementation of a directed, unweighted graph, and then use it to implement the breadth-first algorithms.
Write an implementation of the adjacency list graph representation.
The graph must contain:
1. graph(n): constructor with n nodes and no edges
2. void add_edge(int a, int b)
3. bool has_edge(int a, int b)
4. int count_nodes(): Returns the total number of nodes in this graph.
5. int count_edges() : Returns the total number of edges in this graph.
6. int count_edges(int n): Returns the number of outbound edges from node n.
7. std::vector bfs(int n): Perform a breadth-first search, starting at node n, and returning a vector that gives the distance to every other node.
8. bool is_connected(int a, int b)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
