Data Structures C++

profilepallavisai
sampleMain_v2.cpp

// Computing Structures // Fal 2019 // Project 2 // Sample Main V2 #include <iostream> #include <queue> #include <stack> using namespace std; #define commonValue 0 class CSR { // overload the ostream operator protected: int numRows; //Number of rows of the original matrix int numCols; //Number of columns of the original matrix int noNonSparseValues; //Number of non sparse values of the original matrix int* valueArray; //to store the non cv values int* IA; //to store the IA values int* JA; //to store the JA values public: CSR (); CSR (int n, int m, int numNZV); int getRows(); int getCols(); int getnumNZV(); int getIA(int i); int getJA(int i); int getvalueArray(int i); void setnumNZV(int numNZVlocal); void set_valueArray(int val); void set_JA(int col); void set_IA(int dex); void display_matrix(); void display_valueArray(); void display_JA(); void display_IA(); void display_array(int* arr); int edgeExistent(int u, int v); int* findNeighbours(int node); int* BFS(int start); int* DFS(int start); //other methods as you deem fit }; int main() { int n, m, numNZV; int testValue, count = 0; //matrixA cin >> n >> m >> numNZV; //receive the n, m and numNZV for matrix A CSR* matrixA = new CSR(n, m, numNZV); cout << "MATRIX A ---- Rows, Cols and number of non common values: " << matrixA->getRows() << ", " << matrixA->getCols() << ", " << matrixA->getnumNZV() << endl; //TODO: read in the matrix A from the input file and store it in the given format cout << "The valuesArray for matrix A are : "; matrixA->display_valueArray(); cout << "The JA for matrix A are : "; matrixA->display_JA(); cout << "The IA for matrix A are : "; matrixA->display_IA(); cout << "The matrix A is : " << endl; cout << *matrixA; // overload the ostream operator // necessary declarations for the next incomming variables int u = 0, v = 0; int node = 0; int s = 0; int* sequenceBFS; int* sequenceDFS; cin >> u >> v; // get the vertices to check for edge existance cout << "Edge existance between " << u << " and " << v << ": "; matrixA->edgeExistent(u, v); cout << endl; cin >> node; // get the node for which you need to get all the neighbours cout << "Neighbours of " << node << " are:" << endl; matrixA->findNeighbours(node); cin >> s; // get the start node for BFS and DFS sequenceBFS = matrixA->BFS(s); sequenceDFS = matrixA->DFS(s); cout << "BFS with start node " << s << " is:" << endl; matrixA->display_array(sequenceBFS); cout << "DFS with start node " << s << " is:" << endl; matrixA->display_array(sequenceDFS); return 0; }