MaximumMatching { static int maximise(Graph g, Matching m, int n, IntSet s) { MaximumMatching mm = new MaximumMatching(g, m, n, s); return mm.nMatched; } private  MaximumMatching(Graph graph, Matching matching, int nMatched, IntSet subset);   }
@Test public void simple_augment() throws Exception { Graph g = Graph.fromSmiles("cccc"); Matching m = Matching.empty(g); m.match(1, 2); MaximumMatching.maximise(g, m, 2); assertThat(m.matches(), hasItems(Tuple.of(0, 1), Tuple.of(2, 3))); }
@Test public void simple_augment_subset() throws Exception { Graph g = Graph.fromSmiles("cccc"); Matching m = Matching.empty(g); m.match(1, 2); MaximumMatching.maximise(g, m, 2, IntSet.allOf(0, 1, 2)); assertThat(m.matches(), hasItems(Tuple.of(1, 2))); }
@Test public void furan() throws Exception { Graph g = Graph.fromSmiles("o1cccc1"); IntSet s = IntSet.allOf(1, 2, 3, 4); Matching m = Matching.empty(g); MaximumMatching.maximise(g, m, 0, s); assertThat(m.matches(), hasItems(Tuple.of(1, 2), Tuple.of(3, 4))); }
@Test public void furan_augment() throws Exception { Graph g = Graph.fromSmiles("o1cccc1"); IntSet s = IntSet.allOf(1, 2, 3, 4); Matching m = Matching.empty(g); m.match(2, 3); MaximumMatching.maximise(g, m, 2, s); assertThat(m.matches(), hasItems(Tuple.of(1, 2), Tuple.of(3, 4))); }
@Test public void quinone_subset() throws Exception { Graph g = Graph.fromSmiles("oc1ccc(o)cc1"); Matching m = Matching.empty(g); MaximumMatching.maximise(g, m, 0, IntSet.allOf(2, 3, 6, 7)); assertThat(m.matches(), hasItems(Tuple.of(2, 3), Tuple.of(6, 7))); }
@Test public void napthalene_augment() throws Exception { Graph g = Graph.fromSmiles("C1C=CC2=CCC=CC2=C1"); Matching m = Matching.empty(g); m.match(1, 2); m.match(3, 4); m.match(6, 7); m.match(8, 9); MaximumMatching.maximise(g, m, 8); assertThat(m.matches(), hasItems(Tuple.of(0, 1), Tuple.of(2, 3), Tuple.of(4, 5), Tuple.of(6, 7), Tuple.of(8, 9))); }
@Test public void imidazole() throws Exception { Graph g = Graph.fromSmiles("[nH]1ccnc1"); Matching m = Matching.empty(g); MaximumMatching.maximise(g, m, 0, IntSet.allOf(1, 2, 3, 4)); assertThat(m.matches(), hasItems(Tuple.of(1, 2), Tuple.of(3, 4))); }
@Test public void benzimidazole() throws Exception { Graph g = Graph.fromSmiles("c1nc2ccccc2[nH]1"); Matching m = Matching.empty(g); MaximumMatching.maximise(g, m, 0, IntSet.noneOf(8)); assertThat(m.matches(), hasItems(Tuple.of(0, 1), Tuple.of(2, 3), Tuple.of(4, 5), Tuple.of(6, 7))); }