diff options
author | 2023-08-27 02:13:15 +0200 | |
---|---|---|
committer | 2023-08-27 02:13:15 +0200 | |
commit | cca3b176cea8df8823094c105f612844b649647e (patch) | |
tree | 02e24ecd37228fe170a3b07e4e29570bf97732bf /subprojects/store-query-viatra/src/test/java/tools | |
parent | chore(deps): bump frontend dependencies (diff) | |
download | refinery-cca3b176cea8df8823094c105f612844b649647e.tar.gz refinery-cca3b176cea8df8823094c105f612844b649647e.tar.zst refinery-cca3b176cea8df8823094c105f612844b649647e.zip |
fix: strong represenative election algorithm
Make sure to merge all clusters reachable from source and target.
Diffstat (limited to 'subprojects/store-query-viatra/src/test/java/tools')
-rw-r--r-- | subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/StronglyConnectedComponentsTest.java | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/StronglyConnectedComponentsTest.java b/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/StronglyConnectedComponentsTest.java index 05ea1bbb..37795ff3 100644 --- a/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/StronglyConnectedComponentsTest.java +++ b/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/StronglyConnectedComponentsTest.java | |||
@@ -214,4 +214,48 @@ class StronglyConnectedComponentsTest { | |||
214 | assertThat(resultSet.size(), is(2)); | 214 | assertThat(resultSet.size(), is(2)); |
215 | assertThat(resultSet.get(Tuple.of(2)), is(true)); | 215 | assertThat(resultSet.get(Tuple.of(2)), is(true)); |
216 | } | 216 | } |
217 | |||
218 | @Test | ||
219 | void loopTest() { | ||
220 | var query = Query.of("SymbolViewRepresentative", (builder, p1, p2) -> builder | ||
221 | .clause(v1 -> List.of( | ||
222 | new RepresentativeElectionLiteral(Connectivity.STRONG, friendView, p1, v1), | ||
223 | new RepresentativeElectionLiteral(Connectivity.STRONG, friendView, p2, v1) | ||
224 | ))); | ||
225 | |||
226 | var store = ModelStore.builder() | ||
227 | .symbols(friend) | ||
228 | .with(ViatraModelQueryAdapter.builder() | ||
229 | .queries(query)) | ||
230 | .build(); | ||
231 | |||
232 | var model = store.createEmptyModel(); | ||
233 | var friendInterpretation = model.getInterpretation(friend); | ||
234 | var queryEngine = model.getAdapter(ModelQueryAdapter.class); | ||
235 | var resultSet = queryEngine.getResultSet(query); | ||
236 | |||
237 | friendInterpretation.put(Tuple.of(0, 1), true); | ||
238 | friendInterpretation.put(Tuple.of(1, 2), true); | ||
239 | friendInterpretation.put(Tuple.of(2, 3), true); | ||
240 | friendInterpretation.put(Tuple.of(3, 0), true); | ||
241 | friendInterpretation.put(Tuple.of(3, 4), true); | ||
242 | queryEngine.flushChanges(); | ||
243 | |||
244 | assertThat(resultSet.get(Tuple.of(0, 1)), is(true)); | ||
245 | assertThat(resultSet.get(Tuple.of(1, 2)), is(true)); | ||
246 | assertThat(resultSet.get(Tuple.of(2, 3)), is(true)); | ||
247 | assertThat(resultSet.get(Tuple.of(3, 0)), is(true)); | ||
248 | assertThat(resultSet.get(Tuple.of(3, 4)), is(false)); | ||
249 | |||
250 | friendInterpretation.put(Tuple.of(2, 3), false); | ||
251 | queryEngine.flushChanges(); | ||
252 | |||
253 | assertThat(resultSet.get(Tuple.of(0, 1)), is(false)); | ||
254 | assertThat(resultSet.get(Tuple.of(0, 2)), is(false)); | ||
255 | assertThat(resultSet.get(Tuple.of(0, 3)), is(false)); | ||
256 | assertThat(resultSet.get(Tuple.of(1, 2)), is(false)); | ||
257 | assertThat(resultSet.get(Tuple.of(2, 3)), is(false)); | ||
258 | assertThat(resultSet.get(Tuple.of(3, 0)), is(false)); | ||
259 | assertThat(resultSet.get(Tuple.of(3, 4)), is(false)); | ||
260 | } | ||
217 | } | 261 | } |