#include #include #include "Graph.h" #include "Hash.h" #include "Maze.h" #include "Heap.h" #include "test_utilities.h" struct vertex_cut_info { bool cut, st_cut; }; // YOUR CODE HERE // Given a Graph g, // set the entries of HashTable cut_info such that // for each vertex id w, cut_info[w].cut is 1 if w is a cut vertex and 0 otherwise, // and cut_info[w].st_cut is 1 if w is an s-t cut vertex and 0 otherwise. // (See README for definition of s-t cut vertex.) void find_cut_and_st_cut_vertices(const Graph &g, int s, int t, HashTable& cut_info) { // YOUR CODE HERE } int main() { Maze m; // read the maze in text format from stdin std::cin >> m; // find cut and st-cut vertices HashTable cut_info; find_cut_and_st_cut_vertices(m.graph(), m.get_start_vertex(), m.get_end_vertex(), cut_info); // output the maze with cut vertices marked int cut_count = 0, st_cut_count = 0; Array vertices = m.graph().vertices(); for (int i = 0; i < vertices.size(); ++i) { int v = vertices[i]; if (cut_info[v].cut) { ++cut_count; Array loc = m.loc_of_vertex(v); m.set_text_at(loc[0], loc[1], 'O'); } if (cut_info[v].st_cut) { ++st_cut_count; Array loc = m.loc_of_vertex(v); m.set_text_at(loc[0], loc[1], '#'); } } std::cout << m << std::endl; // output the number of cut vertices std::cout << "Number of cut vertices is " << cut_count << std::endl; std::cout << "Number of st-cut vertices is " << st_cut_count << std::endl; }