### Question:
BarycenterCalculator { public static Double calculateVectorCenter(boolean[] vector) { int truePositionSum = 0; int numberOfTrues = 0; for (int index = 0; index < vector.length; index++) { if (vector[index]) { truePositionSum += index + 1; numberOfTrues++; } } if (numberOfTrues == 0) { return null; } return (double) truePositionSum / numberOfTrues; }  static Double calculateVectorCenter(boolean[] vector);  }### Answer:
@Test public void testUnconnectedNode() throws Exception { boolean[] connections = new boolean[]{false}; Double center = BarycenterCalculator.calculateVectorCenter(connections); assertEquals(null, center); }
@Test public void testConnectedNode() throws Exception { boolean[] connections = new boolean[]{true}; Double center = BarycenterCalculator.calculateVectorCenter(connections); assertEquals(new Double(1), center); }
@Test public void testOrderDependent() throws Exception { boolean[] connections = new boolean[]{true, false}; Double center = BarycenterCalculator.calculateVectorCenter(connections); assertEquals(new Double(1), center); boolean[] connections2 = new boolean[]{false, true}; Double center2 = BarycenterCalculator.calculateVectorCenter(connections2); assertEquals(new Double(2), center2); }