mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-12-19 07:00:35 +08:00
Add KCenters algorithm (#5806)
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package com.thealgorithms.greedyalgorithms;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class KCentersTest {
|
||||
|
||||
@Test
|
||||
public void testFindKCenters() {
|
||||
int[][] distances = {{0, 2, 3, 4}, {2, 0, 5, 1}, {3, 5, 0, 7}, {4, 1, 7, 0}};
|
||||
assertEquals(4, KCenters.findKCenters(distances, 2));
|
||||
assertEquals(2, KCenters.findKCenters(distances, 4));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user