The big problem is that you're not really doing a breadth-first search. You're never adding any elements to the search queue. Instead, you're making a recursive call to
bfs(), which turns this into a depth-first search.
A second issue is the use of instance fields where they should be local variables. Why are
eulerian,
marked,
edgeTo and
cycle not local variables?
Another issue are the names. Make your code clearer by changing your identifiers:
Change | To |
---|
G.V() | graph.numberOfVertices() |
bfs | findEulerianCycle |
i | startVertex |
v | currentVertex |
w | adjacentVertex |