GraphReachability

GraphReachability - #include #include #include #include...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <fstream> #include <iostream> #include <iomanip> #include <cassert> #include <cmath> using namespace std; const int MAX=50; // C = A * B void matMult(int A[][MAX], int B[][MAX], int C[][MAX], int rowsA, int colsA, int rowsB, int colsB, int &rowsC, int &colsC); int main(int argc, char *argv[]) { int vertices; int adjacency[MAX][MAX]; // This allows us to optionally pass a filename on the command line // i.e. ./a.out graph_file.txt // Or, to read the input from the console. if(argc <= 1) { cout << "How many vertices are in the graph? "; cin >> vertices; assert(cin); assert(1 < vertices & vertices cout << "Enter the adjacency matrix for the graph: " << endl; for(int i = 0; i < vertices; i++) for(int j = 0; j < vertices; j++) { cin >> adjacency[i][j]; assert(cin); assert(adjacency[i][j] == 1 || adjacency[i][j] == 0); } } else { ifstream fin(argv[1]); fin >> vertices; assert(fin); assert(1 < vertices & vertices for(int i = 0; i < vertices; i++) for(int j = 0; j < vertices; j++) {
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/28/2010 for the course CSCI 1113 taught by Professor Staff during the Spring '08 term at Minnesota.

Page1 / 2

GraphReachability - #include #include #include #include...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online