Skip to content

Commit

Permalink
review edits
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbenjamin committed Jul 2, 2020
1 parent 4904fc8 commit cfa1b7b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,8 @@ public BaseGraph<V,E> clone() {
return (BaseGraph<V,E>) super.clone();
}

public abstract void addEdge(Object o, SeqVertex a, SeqVertex d, SeqVertex c);

/**
* General iterator that can iterate over all vertices in a BaseGraph, following either
* incoming, outgoing edge (as well as both or none) edges. Supports traversal of graphs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,52 @@ public void testAdaptivePruningWithAdjacentBadEdges() {
}
}

// test that in graph with good path A -> B -> C and bad edges A -> D and E -> C with a bubble with edges F, G between D and E
// that the bad bubble does not harm pruning.
// we test with and without a true variant path A -> H -> C
@Test
public void testAdaptivePruningWithBadBubble() {
final int goodMultiplicity = 1000;
final int variantMultiplicity = 50;
final int badMultiplicity = 5;

final SeqVertex source = new SeqVertex("source");
final SeqVertex sink = new SeqVertex("sink");
final SeqVertex A = new SeqVertex("A");
final SeqVertex B = new SeqVertex("B");
final SeqVertex C = new SeqVertex("C");
final SeqVertex D = new SeqVertex("D");
final SeqVertex E = new SeqVertex("E");
final SeqVertex F = new SeqVertex("F");
final SeqVertex G = new SeqVertex("G");
final SeqVertex H = new SeqVertex("H");


for (boolean variantPresent : new boolean[] {false, true}) {
final SeqGraph graph = new SeqGraph(20);

graph.addVertices(source, A, B, C, D, E, F, G, sink);
graph.addEdges(() -> new BaseEdge(true, goodMultiplicity), source, A, B, C, sink);
graph.addEdges(() -> new BaseEdge(false, badMultiplicity), A, D);
graph.addEdges(() -> new BaseEdge(false, badMultiplicity), D, F, E);
graph.addEdges(() -> new BaseEdge(false, badMultiplicity), D, G, E);
graph.addEdges(() -> new BaseEdge(false, badMultiplicity), E, C);

if (variantPresent) {
graph.addVertices(H);
graph.addEdges(() -> new BaseEdge(false, variantMultiplicity), A, H, C);
}

final ChainPruner<SeqVertex, BaseEdge> pruner = new AdaptiveChainPruner<>(0.01, 2.0, 2.0, 50);
pruner.pruneLowWeightChains(graph);

Assert.assertFalse(graph.containsVertex(D));
if (variantPresent) {
Assert.assertTrue(graph.containsVertex(E));
}
}
}

@DataProvider(name = "chainPrunerData")
public Object[][] getChainPrunerData() {
final RandomGenerator rng = RandomGeneratorFactory.createRandomGenerator(new Random(9));
Expand Down

0 comments on commit cfa1b7b

Please sign in to comment.