### Question:
HierholzerEulerianCycle implements EulerianCycleAlgorithm<V, E> { public GraphPath<V, E> getEulerianCycle(Graph<V, E> g) { if (!isEulerian(g)) { throw new IllegalArgumentException("Graph is not Eulerian"); } else if (g.vertexSet().size() == 0) { throw new IllegalArgumentException("Null graph not permitted"); } else if (GraphTests.isEmpty(g)) { return GraphWalk.emptyWalk(g); } initialize(g); while (verticesHead != null) { EdgeNode whereToInsert = verticesHead.insertLocation; Pair<EdgeNode, EdgeNode> partialCycle = computePartialCycle(); updateGraphAndInsertLocations(partialCycle, verticesHead); if (whereToInsert == null) { eulerianHead = partialCycle.getFirst(); } else { partialCycle.getSecond().next = whereToInsert.next; whereToInsert.next = partialCycle.getFirst(); } } GraphWalk<V, E> walk = buildWalk(); cleanup(); return walk; }  boolean isEulerian(Graph<V, E> graph); GraphPath<V, E> getEulerianCycle(Graph<V, E> g);  }### Answer:
@Test public void testEmptyWithSingleVertexUndirected() { Graph<Integer, DefaultEdge> g = new Pseudograph<>(DefaultEdge.class); g.addVertex(1); GraphPath<Integer, DefaultEdge> cycle = new HierholzerEulerianCycle<Integer, DefaultEdge>().getEulerianCycle(g); assertEulerian(cycle); }
@Test public void testEmptyMultipleVerticesUndirected() { Graph<Integer, DefaultEdge> g = new Pseudograph<>(DefaultEdge.class); g.addVertex(1); g.addVertex(2); g.addVertex(3); g.addVertex(4); g.addVertex(5); GraphPath<Integer, DefaultEdge> cycle = new HierholzerEulerianCycle<Integer, DefaultEdge>().getEulerianCycle(g); assertEulerian(cycle); }
@Test public void testEmptyWithSingleVertexDirected() { Graph<Integer, DefaultEdge> g = new DirectedPseudograph<>(DefaultEdge.class); g.addVertex(1); GraphPath<Integer, DefaultEdge> cycle = new HierholzerEulerianCycle<Integer, DefaultEdge>().getEulerianCycle(g); assertEulerian(cycle); }
@Test public void testEmptyMultipleVerticesDirected() { Graph<Integer, DefaultEdge> g = new DirectedPseudograph<>(DefaultEdge.class); g.addVertex(1); g.addVertex(2); g.addVertex(3); g.addVertex(4); g.addVertex(5); GraphPath<Integer, DefaultEdge> cycle = new HierholzerEulerianCycle<Integer, DefaultEdge>().getEulerianCycle(g); assertEulerian(cycle); }