main.cpp - if (g1u.dfs(2, 5)) cout <<...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
// The following statements should be included in your main() function, // in the order as specified. Graph g1u = Graph("g1.txt"); // undirected graph Graph g1d = Graph("g1.txt", "d"); // directed graph Graph g2d = Graph("g2.txt", "d"); // directed graph Graph g3u = Graph("g3.txt"); // undirected graph Graph g4u = Graph("g4.txt"); // undirected graph // test numOfPaths() for undirected graph cout << "test numOfPath() for g1u" << endl; g1u.numOfPaths(1); g1u.numOfPaths(3); // test numOfPaths() for directed graph cout << "test numOfPath() for g1d" << endl; g1d.numOfPaths(1); g1d.numOfPaths(3); // test dfs() for undirected graph if (g1u.dfs(1, 7)) cout << "g1u.dfs(1, 7) is true" << endl; else cout << "g1u.dfs(1, 7) is false" << endl;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: if (g1u.dfs(2, 5)) cout &lt;&lt; &quot;g1u.dfs(2, 5) is true&quot; &lt;&lt; endl; else cout &lt;&lt; &quot;g1u.dfs(2, 5) is false&quot; &lt;&lt; endl; // test dfs() for directed graph if (g1d.dfs(1, 7)) cout &lt;&lt; &quot;g1d.dfs(1, 7) is true&quot; &lt;&lt; endl; else cout &lt;&lt; &quot;g1d.dfs(1, 7) is false&quot; &lt;&lt; endl; if (g1d.dfs(2, 5)) cout &lt;&lt; &quot;g1d.dfs(2, 5) is true&quot; &lt;&lt; endl; else cout &lt;&lt; &quot;g1d.dfs(2, 5) is false&quot; &lt;&lt; endl; // test shortestPath() for directed graph cout &lt;&lt; &quot;a shortest path from 1 to 9 in g2d:&quot; &lt;&lt; endl; g2d.shortestPath(1, 9); cout &lt;&lt; &quot;a shortest path from 4 to 1 in g2d:&quot; &lt;&lt; endl; g2d.shortestPath(4, 1); // test EulerPath() for extra credit: // g3u.EulerPath(); // g4u.EulerPath();...
View Full Document

This document was uploaded on 06/13/2011.

Ask a homework question - tutors are online