I have been implementing the graph algorithms in
java.
i was trying to do it in elaborate way as they do in java.
inputting graph from the file and then doing bfs on it.
here is my code that in java.
TraversalUtils.java
TraversalUtilTests.java
can anyone please tell me why i am getting it like this on running TraversalUtilsTest.java.
in the while loop, i am trying to run bfs again and again from node 1 of different graphs.
It do not seem logical to me at all
Please help..
This is the input output that i have faced
Enter file code : 1
1
2
3
Enter file code : Exception in
thread "main" java.util.NoSuchElementException
at java.util.Scanner.throwFor(Unknown Source)
at java.util.Scanner.next(Unknown Source)
at java.util.Scanner.nextInt(Unknown Source)
at java.util.Scanner.nextInt(Unknown Source)
at graph.GraphMaker.getGraph(GraphMaker.java:30)
at graph.TraversalUtilsTest.main(TraversalUtilsTest.java:10)
just in case you need, the other files are these.
Graph.java
GraphMaker.java
also, graph1.txt is file like this.
3
1 2
2 3
3 1
Thank you very much.