Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: Add Hierholzer's Algorithm for Eulerian Circuits
  • Loading branch information
sairamsharan committed Oct 11, 2025
commit 456e0cfd6c57218c42103515860bbc62a746ec5b
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
package com.thealgorithms.graph;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.*;
import java.util.*;
import org.junit.jupiter.api.Test;

public class HierholzerAlgorithmTest {

@Test
public void testFindsEulerianCircuitInSimpleTriangleGraph() {
// Create a simple triangle graph where a circuit definitely exists: 0-1, 1-2, 2-0
// A simple triangle graph where a circuit definitely exists: 0-1, 1-2, 2-0
Map<Integer, LinkedList<Integer>> graph = new HashMap<>();
graph.put(0, new LinkedList<>(Arrays.asList(1, 2)));
graph.put(1, new LinkedList<>(Arrays.asList(0, 2)));
Expand Down Expand Up @@ -50,7 +42,7 @@ public void testFailsForGraphWithOddDegreeVertices() {
// The find method should return an empty list
assertTrue(algorithm.findEulerianCircuit().isEmpty());
}

@Test
public void testFailsForDisconnectedGraph() {
// Create a graph with two separate triangles (0-1-2 and 3-4-5)
Expand Down
Loading