Search in sources :

Example 1 with LongTarjan

use of com.b2international.commons.graph.LongTarjan in project snow-owl by b2ihealthcare.

the class LongTarjanTest method smallBatchSize.

@Test
public void smallBatchSize() throws Exception {
    final LongKeyLongMap followerMap = PrimitiveMaps.newLongKeyLongOpenHashMap();
    followerMap.put(1, 2);
    followerMap.put(2, 3);
    followerMap.put(3, 4);
    followerMap.put(4, 1);
    followerMap.put(5, 3);
    followerMap.put(6, 2);
    followerMap.put(7, 8);
    followerMap.put(8, 6);
    final LongTarjan tarjan = new LongTarjan(3, currentId -> LongCollections.singletonSet(followerMap.get(currentId)));
    final List<LongSet> actual = tarjan.run(followerMap.keySet());
    assertEquals(ImmutableList.of(PrimitiveSets.newLongOpenHashSet(1L, 2L, 3L, 4L), PrimitiveSets.newLongOpenHashSet(5L, 6L, 8L), PrimitiveSets.newLongOpenHashSet(7L)), actual);
}
Also used : LongSet(com.b2international.collections.longs.LongSet) LongKeyLongMap(com.b2international.collections.longs.LongKeyLongMap) LongTarjan(com.b2international.commons.graph.LongTarjan) Test(org.junit.Test)

Aggregations

LongKeyLongMap (com.b2international.collections.longs.LongKeyLongMap)1 LongSet (com.b2international.collections.longs.LongSet)1 LongTarjan (com.b2international.commons.graph.LongTarjan)1 Test (org.junit.Test)1