I am having trouble adding numbers read from a file with BufferedReader, using Tokenizer to split the numbers up by " " - space and adding them to an adjacency matrix.
Thanks for your help in advance!
Below is the text file and my code, that I have at the moment.
this is the output without the two for loops putting the tokens into the adjMatrix
Lines 36-40 attempt to get the next x*j tokens when you are already pulling out the next token on line 31. You might want to make 36-40 your main loop and do away with the while() loop.
So SORRY for the extremely late replies...I had a death in the family and didn't take it very well. But back to normal now. Thank you so much for the replies and suggestions!
@Jesper de Jong: how would I go about doing a split() so it can be in the adjMatrix
@Carey Brown: thanks I will try that
@Knute Snortum: ah, thank you for pointing that out! That should be just
I'm also looking for a split() since Jesper suggested that it would be better. I will update my progress
Okay, I fixed that. With something else. NOW, I am trying to save the first encounters of DFS into an array so it can be printed for later.
By first encounters : I mean what is first pushed on the stack or visited first.
Here is my now code.
This is the output
** edit.
Just found out that my traversal is WRONG so I am now trying to figure out what's going on here
So what is the algorithm for the traversal? You should turn your computer off and write the algorithm on a piece of paper. Then you can turn it into code. You will probably have to delete all the old code if it is not working correctly.
I can't renounce my name. It's on all my stationery! And hinted in this tiny ad:
Gift giving made easy with the permaculture playing cards