/******************************************************************** Author: Dana Vrajitoru, IUSB, CS Class: C243, Spring 2004 File name: graph.cc Last updated: April 20, 2004. Description: Implementation of a class that implements a graph. *********************************************************************/ #include "graph.h" #include #include #include // Default constructor - makes an empty undirected graph. Graph::Graph() { nr_vertices = 0; nr_edges = 0; directed = false; } // Destructor - empty the lists and the vector. Graph::~Graph() { Make_empty(); } // Starts the graph over. void Graph::Make_empty() { if (nr_vertices) { for (int i=0; i> nrv; Init(nrv); while (!fin.eof()) { fin >> v1 >> v2; if (fin.good()) Add_edge(v1, v2); } fin.close(); } // Simple print of the graph. void Graph::Print() { int i; if (directed) cout << "The graph is directed" << endl; else cout << "The graph is undirected" << endl; cout << "The graph contains " << nr_vertices << " vertices and " << nr_edges << " edges" << endl; if (nr_vertices) { cout << "The adjacency list for each vertex is:" << endl; for (i=0; i