Write a program called FindPath.java to solve the following problem. The program will be given an input consisting of a series of positive integers separated by white space representing a directed graph as follows. There will always be an even number of integers in the input, and you may assume that input will consist of at least two integers and is of the form specified. It is not necessary to code for nonsense input files or nonsense command lines when running your program. The input is to be regarded as a series of pairs of integers. Each integer represents a node in the graph, and each pair represents a directed edge in the graph, from the first element of the pair to the second element of the pair. The graph represented by the input will have at most 10,000 nodes, which you may assume to be numbered from 1 to the maximum integer in the input. Note that it is not necessary for a node to have any edges attached to it, in which case it will not occur in the input file.
Here is a sample input file. The program should exhibit detailed behavior exemplified as follows, where the message will indicated whether or not there is a path between the specified pair of nodes in the graph, and is an error message if any number supplied on the command line is not a node in the input data. You may freely use any of the machinery to represent graphs and compute with graphs developed in class, however, you may NOT use any classes that come with Java apart from those used in teaching this class. $ java FindPath 22 92
Get Free Quote!
419 Experts Online