### Question:
TransientAdjacencyList implements AdjacencyList { static long computeAdjacencyByteSize(long avgDegree, long nodeCount, long delta) { long firstAdjacencyIdAvgByteSize = (avgDegree > 0) ? ceilDiv(encodedVLongSize(nodeCount), 2) : 0L; int relationshipByteSize = encodedVLongSize(delta); int degreeByteSize = Integer.BYTES; long compressedAdjacencyByteSize = relationshipByteSize * Math.max(0, (avgDegree - 1)); return (degreeByteSize + firstAdjacencyIdAvgByteSize + compressedAdjacencyByteSize) * nodeCount; } TransientAdjacencyList(byte[][] pages); static MemoryEstimation compressedMemoryEstimation(long avgDegree, long nodeCount); static MemoryEstimation compressedMemoryEstimation(boolean undirected); static MemoryEstimation compressedMemoryEstimation(RelationshipType relationshipType, boolean undirected); static MemoryEstimation uncompressedMemoryEstimation(boolean undirected); static MemoryEstimation uncompressedMemoryEstimation(RelationshipType relationshipType, boolean undirected); @Override int degree(long index); @Override void close(); @Override Cursor cursor(long offset); @Override DecompressingCursor rawDecompressingCursor(); @Override DecompressingCursor decompressingCursor(long offset); static final int PAGE_SHIFT; static final int PAGE_SIZE; static final long PAGE_MASK; }### Answer:
@Test void shouldComputeAdjacencyByteSize() { long avgDegree = 1000; long nodeCount = 100_000_000; long delta = 100_000; long firstAdjacencyIdAvgByteSize = ceilDiv(ceilDiv(64 - Long.numberOfLeadingZeros(nodeCount - 1), 7), 2); long relationshipByteSize = ceilDiv(64 - Long.numberOfLeadingZeros(delta - 1), 7); int degreeByteSize = 4; long compressedAdjacencyByteSize = relationshipByteSize * (avgDegree - 1); long expected = (degreeByteSize + firstAdjacencyIdAvgByteSize + compressedAdjacencyByteSize) * nodeCount; assertEquals(expected, computeAdjacencyByteSize(avgDegree, nodeCount, delta)); }
@Test void shouldComputeAdjacencyByteSizeNoNodes() { long avgDegree = 0; long nodeCount = 0; long delta = 0; assertEquals(0, computeAdjacencyByteSize(avgDegree, nodeCount, delta)); }
@Test void shouldComputeAdjacencyByteSizeNoRelationships() { long avgDegree = 0; long nodeCount = 100; long delta = 0; assertEquals(400, computeAdjacencyByteSize(avgDegree, nodeCount, delta)); }