mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
parent
f40cb430fa
commit
df7b3957e9
|
@ -310,6 +310,9 @@ class IrreducibleGraphSplitter {
|
|||
}
|
||||
copyMap[node] = copyIndex;
|
||||
int realNodeCount = realNodes[node].size();
|
||||
if (node == top) {
|
||||
realNodeCount -= realNodesCopies.length;
|
||||
}
|
||||
subgraphRealNodes[copyIndex] = Arrays.copyOfRange(realNodesCopies, realNodeCopiesIndex,
|
||||
realNodeCopiesIndex + realNodeCount);
|
||||
realNodeCopiesIndex += realNodeCount;
|
||||
|
|
|
@ -326,6 +326,55 @@ public class GraphTest {
|
|||
assertFalse("Should be reducible", GraphUtils.isIrreducible(result));
|
||||
assertTrue("Should be equivalent", isEquivalent(backend, graph));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void irreducibleGraphSplit7() {
|
||||
var builder = new GraphBuilder();
|
||||
addEdges(builder, 0, 35);
|
||||
addEdges(builder, 1, 28);
|
||||
addEdges(builder, 2, 25);
|
||||
addEdges(builder, 3, 2, 15);
|
||||
addEdges(builder, 4, 27);
|
||||
addEdges(builder, 5, 13, 14);
|
||||
addEdges(builder, 6, 8, 31);
|
||||
addEdges(builder, 7, 11, 12);
|
||||
addEdges(builder, 9, 10, 33);
|
||||
addEdges(builder, 11, 27);
|
||||
addEdges(builder, 12, 5);
|
||||
addEdges(builder, 13, 26);
|
||||
addEdges(builder, 14, 3);
|
||||
addEdges(builder, 15, 23);
|
||||
addEdges(builder, 16, 2, 24);
|
||||
addEdges(builder, 17, 22);
|
||||
addEdges(builder, 18, 23);
|
||||
addEdges(builder, 19, 21, 34);
|
||||
addEdges(builder, 20, 22);
|
||||
addEdges(builder, 22, 18, 19);
|
||||
addEdges(builder, 23, 16, 17);
|
||||
addEdges(builder, 24);
|
||||
addEdges(builder, 25, 1, 38);
|
||||
addEdges(builder, 26, 4, 29);
|
||||
addEdges(builder, 27, 6, 30);
|
||||
addEdges(builder, 28, 36, 37);
|
||||
addEdges(builder, 29, 3);
|
||||
addEdges(builder, 30, 5);
|
||||
addEdges(builder, 31, 7);
|
||||
addEdges(builder, 32, 7);
|
||||
addEdges(builder, 33, 7);
|
||||
addEdges(builder, 34, 20);
|
||||
addEdges(builder, 35, 9, 32);
|
||||
|
||||
var graph = builder.build();
|
||||
var backend = new DefaultGraphSplittingBackend(graph);
|
||||
var weights = new int[graph.size()];
|
||||
Arrays.fill(weights, 1);
|
||||
GraphUtils.splitIrreducibleGraph(graph, weights, backend);
|
||||
var result = backend.getGraph();
|
||||
|
||||
assertTrue("Should be irreducible", GraphUtils.isIrreducible(graph));
|
||||
assertFalse("Should be reducible", GraphUtils.isIrreducible(result));
|
||||
assertTrue("Should be equivalent", isEquivalent(backend, graph));
|
||||
}
|
||||
|
||||
private static void addEdges(GraphBuilder builder, int from, int... to) {
|
||||
for (int target : to) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user