Graham scan algorithm (#3903)

* Added Graham scan algorithm #3894

* Added Graham scan algorithm (#3894)

---------

Co-authored-by: Stronshade <diegobrocker1999@gmail.com>
This commit is contained in:
Stronshade
2023-02-25 07:01:51 -06:00
committed by GitHub
parent be13981e94
commit 6d13d95e41
2 changed files with 174 additions and 0 deletions

View File

@ -0,0 +1,19 @@
package com.thealgorithms.geometry;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class GrahamScanTest {
@Test
void testGrahamScan() {
GrahamScan.Point[] points = {new GrahamScan.Point(0, 3), new GrahamScan.Point(1, 1),
new GrahamScan.Point(2, 2), new GrahamScan.Point(4, 4),
new GrahamScan.Point(0, 0), new GrahamScan.Point(1, 2),
new GrahamScan.Point(3, 1), new GrahamScan.Point(3, 3)};
String expectedResult = "[(0, 0), (3, 1), (4, 4), (0, 3)]";
GrahamScan graham = new GrahamScan(points);
assertEquals(expectedResult, graham.hull().toString());
}
}