main.java - if (g1u.dfs(2, 5))...

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() method, // in the order as specified. Graph g1u = new Graph("g1.txt"); // undirected graph Graph g1d = new Graph("g1.txt", "d"); // directed graph Graph g2d = new Graph("g2.txt", "d"); // directed graph Graph g3u = new Graph("g3.txt"); // undirected graph Graph g4u = new Graph("g4.txt"); // undirected graph // test numOfPaths() for undirected graph System.out.println("test numOfPath() for g1u"); g1u.numOfPaths(1); g1u.numOfPaths(3); // test numOfPaths() for directed graph System.out.println("test numOfPath() for g1d"); g1d.numOfPaths(1); g1d.numOfPaths(3); // test dfs() for undirected graph if (g1u.dfs(1, 7)) System.out.println("g1u.dfs(1, 7) is true"); else System.out.println("g1u.dfs(1, 7) is false");
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)) System.out.println("g1u.dfs(2, 5) is true"); else System.out.println("g1u.dfs(2, 5) is false"); // test dfs() for directed graph if (g1d.dfs(1, 7)) System.out.println("g1d.dfs(1, 7) is true"); else System.out.println("g1d.dfs(1, 7) is false"); if (g1d.dfs(2, 5)) System.out.println("g1d.dfs(2, 5) is true"); else System.out.println("g1d.dfs(2, 5) is false"); // test shortestPath() for directed graph System.out.println("a shortest path from 1 to 9 in g2d:"); g2d.shortestPath(1, 9); System.out.println("a shortest path from 4 to 1 in g2d:"); 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