Indirect Path

I am working off of the following pseudo code
========================
Input       Size: # of cities
      Map: 2d Array
      Start: beginning city
      End: destination city

      Output      isPath(Boolean)

   Create empty queue, Q
         Create an array visited(size), set all entries to false
         Set visited[start] = true
         Q.enqueue(start)

         While Q is not empty
               Curr   Q.dequeue
               If curr = end
                     Return true
                     End if

         For each reachable neighbor of curr
               If neighbor is unvisted
                     Visited(neighbor)  true
                     Q.enqueue(neighbor)
                     End if
         End for
         End while
            Return false
================

I need  read in a file that looks similar to this

5
0
-1,0
1,-1,0
-1,1,1,0
-1,-1,-1,1,0

1 = path
-1 = no direct path
0 = means same as direct path except it that row and column number are that same.

The first line is how many rows and columns there are, in this case 5 for each. Keep in mind the file might have up to as many as a 1000 rows and columns. I can read in the file and set up the various variables and the following code works good to find a direct path. My difficulty is coding to find the indirect path. Which is this part of the pseudo code
========================
While Q is not empty
               Curr   Q.dequeue
               If curr = end
                     Return true
                     End if

         For each reachable neighbor of curr
               If neighbor is unvisted
                     Visited(neighbor)  true
                     Q.enqueue(neighbor)
                     End if
         End for
         End while
            Return false
========================

I can usually figure this stuff out on my own but I have been very sick and have not been able to do anything since I put the following code together. The problem is I have a deadline of 12hrs from now to have this completed. The experts in this link http://www.experts-exchange.com/Programming/Languages/Java/Q_26904749.html  have been helping me but I am in a panic to get this done, so please HELP.


public class CityPathQueue {

   private Queue<Integer> queCity =  new LinkedList<Integer>();
   private Queue<Integer> a = new LinkedList<Integer>();
   private HashSet<Integer> b = new HashSet<Integer>();
   private FileInputStream fstream;
   private DataInputStream in;
   private BufferedReader br;
   private int[][] map;
   private boolean[] visited;
   private int currentCity = -1;
   /**
    * 
    */
   public CityPathQueue() 
   {
	  // TODO Auto-generated constructor stub
   }
   
   public CityPathQueue(String infilename)  throws IOException
   {
	  String strLine;
	  int 	intRow = 0,
		 	intSize;
	//for (int i = 0; i < intEnd; i++)
	  try
	  {
		 // Get the object of DataInputStream
		 fstream = new FileInputStream(infilename);
		 in = new DataInputStream(fstream);
		 br = new BufferedReader(new InputStreamReader(in));
		 //retrieve the the first line which will be the number of cities
		 strLine = br.readLine();
		 intSize = Integer.parseInt(strLine);
		 //dimension both arrays
		 visited = new boolean[intSize];
		 map = new int[intSize][intSize];
		 
		 for (int i = 0; i < intSize; i++)
		 {
			visited[i] = false;
		 }
		
		 //Read File Line By Line
		 while ((strLine = br.readLine()) != null)   
		 {
			String[] test = strLine.split(",");
			for (int j = 0; j < test.length; j++)
			{
			   map[intRow][j] = Integer.parseInt(test[j]);
			}
			intRow++;
		 }

	  }catch (Exception e)
	  {//Catch exception if any
		 System.err.println("Error: " + e.getMessage());
		 in.close();
	  }
	  in.close();

   }
   
   public int isDirect(int start, int end)
   {
	  int 	intStart = start,
	 		intEnd = end;
	  //flip the order of the cities if the destination city is less than
	  //the strat city. This way the rest of the map does not need
	  //to filled. Also a 2D array starts cheking at the row and then 
	  //the column so to pass the args correctly the end city
	  //goes into the first dimension of the array.
	  if (end < start)
	  {
		 intStart = end;
		 intEnd = start;
	  }
	  queCity.offer(intStart - 1);
	  visited[intStart - 1] = true;
	  return map[intEnd - 1][intStart - 1];
   }

Open in new window

LVL 44
CrazyOneAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

for_yanCommented:
But I sent you the program which works.
0
for_yanCommented:
0
mccarlIT Business Systems Analyst / Software DeveloperCommented:
for_yan, as it is fairly obvious that it is an academic question, you shouldn't be just providing code to be used as is, but should be helping the question author to arrive at their own solution
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.