Skip to content

Commit 0a65994

Browse files
committed
Added Hierholzer Algorith to find Eulerian Path
1 parent 7bd12a2 commit 0a65994

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/main/java/com/thealgorithms/graph/HierholzerEulerianPath.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* <b>Time Complexity:</b> O(E + V).<br>
2929
* <b>Space Complexity:</b> O(V + E).
3030
* </p>
31-
*
31+
*
3232
* @author <a href="https://en.wikipedia.org/wiki/Eulerian_path#Hierholzer's_algorithm">Wikipedia: Hierholzer algorithm</a>
3333
*/
3434
public class HierholzerEulerianPath {

src/test/java/com/thealgorithms/graph/HierholzerEulerianPathTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77

88
/**
99
* Unit tests for {@link HierholzerEulerianPath}.
10-
*
10+
*
1111
* This test suite validates Hierholzer's Algorithm implementation
1212
* for finding Eulerian Paths and Circuits in directed graphs.
13-
*
13+
*
1414
* <p>Coverage includes:
1515
* <ul>
1616
* <li>Basic Eulerian Circuit</li>
@@ -65,7 +65,7 @@ void testNoEulerianPathExists() {
6565
HierholzerEulerianPath solver = new HierholzerEulerianPath(graph);
6666
List<Integer> result = solver.findEulerianPath();
6767

68-
assertEquals(result.get(0), result.get(result.size()-1));
68+
assertEquals(result, Arrays.asList(0, 1, 2));
6969
}
7070

7171
@Test
@@ -151,7 +151,7 @@ void testMultipleEdgesBetweenSameNodes() {
151151
List<Integer> result = solver.findEulerianPath();
152152

153153
// Hava a Eulerian Path but not a Eulerian Circuit
154-
assertEquals(result, Arrays.asList(0,1,2,0,1));
154+
assertEquals(result, Arrays.asList(0, 1, 2, 0, 1));
155155
}
156156

157157
@Test

0 commit comments

Comments
 (0)