mirror of
https://github.com/apache/maven-mvnd.git
synced 2025-09-10 21:22:03 +00:00
A test for DAG width wrong for triple interdependent graph #287
This commit is contained in:
@@ -33,14 +33,18 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||||||
|
|
||||||
public class DagWidthTest {
|
public class DagWidthTest {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* A B
|
||||||
|
* /|\ / \
|
||||||
|
* C D E F
|
||||||
|
* \|
|
||||||
|
* G
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
void testSimpleGraph() {
|
void testSimpleGraph() {
|
||||||
//
|
//
|
||||||
// A B
|
|
||||||
// / | \ / \
|
|
||||||
// C D E F
|
|
||||||
// \/
|
|
||||||
// G
|
|
||||||
Map<String, List<String>> upstreams = new HashMap<>();
|
Map<String, List<String>> upstreams = new HashMap<>();
|
||||||
upstreams.put("A", Collections.emptyList());
|
upstreams.put("A", Collections.emptyList());
|
||||||
upstreams.put("B", Collections.emptyList());
|
upstreams.put("B", Collections.emptyList());
|
||||||
@@ -54,11 +58,77 @@ public class DagWidthTest {
|
|||||||
assertEquals(4, new DagWidth<>(graph).getMaxWidth(12));
|
assertEquals(4, new DagWidth<>(graph).getMaxWidth(12));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* A
|
||||||
|
* /|
|
||||||
|
* B |
|
||||||
|
* \|
|
||||||
|
* C
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
void tripleLinearGraph() {
|
||||||
|
Map<String, List<String>> upstreams = new HashMap<>();
|
||||||
|
upstreams.put("A", Collections.emptyList());
|
||||||
|
upstreams.put("B", Collections.singletonList("A"));
|
||||||
|
upstreams.put("C", Arrays.asList("A", "B"));
|
||||||
|
DependencyGraph<String> graph = newGraph(upstreams);
|
||||||
|
assertEquals(1, new DagWidth<>(graph).getMaxWidth());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* A
|
||||||
|
* /|\
|
||||||
|
* B C D
|
||||||
|
* /|\ \|
|
||||||
|
* E F G H
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
void multilevelSum() {
|
||||||
|
Map<String, List<String>> upstreams = new HashMap<>();
|
||||||
|
upstreams.put("A", Collections.emptyList());
|
||||||
|
upstreams.put("B", Collections.singletonList("A"));
|
||||||
|
upstreams.put("C", Collections.singletonList("A"));
|
||||||
|
upstreams.put("D", Collections.singletonList("A"));
|
||||||
|
upstreams.put("E", Collections.singletonList("B"));
|
||||||
|
upstreams.put("F", Collections.singletonList("B"));
|
||||||
|
upstreams.put("G", Collections.singletonList("B"));
|
||||||
|
upstreams.put("H", Arrays.asList("C", "D"));
|
||||||
|
DependencyGraph<String> graph = newGraph(upstreams);
|
||||||
|
assertEquals(5, new DagWidth<>(graph).getMaxWidth());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* A
|
||||||
|
* /|\
|
||||||
|
* B C D
|
||||||
|
* |
|
||||||
|
* E
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
void wide() {
|
||||||
|
Map<String, List<String>> upstreams = new HashMap<>();
|
||||||
|
upstreams.put("A", Collections.emptyList());
|
||||||
|
upstreams.put("B", Collections.singletonList("A"));
|
||||||
|
upstreams.put("C", Collections.singletonList("A"));
|
||||||
|
upstreams.put("D", Collections.singletonList("A"));
|
||||||
|
upstreams.put("E", Collections.singletonList("D"));
|
||||||
|
DependencyGraph<String> graph = newGraph(upstreams);
|
||||||
|
assertEquals(3, new DagWidth<>(graph).getMaxWidth());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* A
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
void testSingle() {
|
void testSingle() {
|
||||||
//
|
|
||||||
// A
|
|
||||||
//
|
|
||||||
Map<String, List<String>> upstreams = new HashMap<>();
|
Map<String, List<String>> upstreams = new HashMap<>();
|
||||||
upstreams.put("A", Collections.emptyList());
|
upstreams.put("A", Collections.emptyList());
|
||||||
DependencyGraph<String> graph = newGraph(upstreams);
|
DependencyGraph<String> graph = newGraph(upstreams);
|
||||||
|
Reference in New Issue
Block a user