### Question:
WriteOptimizedGraphity extends SocialGraph { @Override public void createFriendship(final Node following, final Node followed) { for (Relationship followship : following.getRelationships( SocialGraphRelationshipType.FOLLOW, Direction.OUTGOING)) { if (followship.getEndNode().equals(followed)) { return; } } following.createRelationshipTo(followed, SocialGraphRelationshipType.FOLLOW); } WriteOptimizedGraphity(final AbstractGraphDatabase graph); @Override void createFriendship(final Node following, final Node followed); @Override void createStatusUpdate(final long timestamp, final Node user,
			StatusUpdate content); @Override List<JSONObject> readStatusUpdates(final Node poster,
			final Node user, final int numItems, boolean ownUpdates); @Override boolean removeFriendship(final Node following, final Node followed); @Override boolean deleteStatusUpdate(final Node user, final Node statusUpdate);  }### Answer:
@Test public void testCreateFriendship_Regular() { this.algorithm.createFriendship(this.USER_A, this.USER_B); this.algorithm.createFriendship(this.USER_A, this.USER_C); this.algorithm.createFriendship(this.USER_A, this.USER_D); this.algorithm.createFriendship(this.USER_A, this.USER_E); this.algorithm.createFriendship(this.USER_B, this.USER_A); this.algorithm.createFriendship(this.USER_B, this.USER_D); this.algorithm.createFriendship(this.USER_C, this.USER_A); this.algorithm.createFriendship(this.USER_C, this.USER_E); this.algorithm.createFriendship(this.USER_D, this.USER_C); final Map<Node, int[]> sortedCounts = new HashMap<Node, int[]>(); sortedCounts.put(this.USER_A, new int[] { 4, 2 }); sortedCounts.put(this.USER_B, new int[] { 2, 1 }); sortedCounts.put(this.USER_C, new int[] { 2, 2 }); sortedCounts.put(this.USER_D, new int[] { 1, 2 }); sortedCounts.put(this.USER_E, new int[] { 0, 2 }); int[] relationshipCount; for (Node user : AlgorithmTests.USERS) { relationshipCount = sortedCounts.get(user); assertEquals(AlgorithmTest.getNumberOfRelationships(user .getRelationships(SocialGraphRelationshipType.FOLLOW, Direction.OUTGOING)), relationshipCount[0]); assertEquals(AlgorithmTest.getNumberOfRelationships(user .getRelationships(SocialGraphRelationshipType.FOLLOW, Direction.INCOMING)), relationshipCount[1]); } this.transaction.success(); }