### Question:
TopologyLayouts { public static void center(Topology topology) { TopologyBoundaries boundaries = computeBoundaries(topology); double optimalMarginX = (topology.getWidth() - (boundaries.xMax - boundaries.xMin)) / 2; double shiftX = optimalMarginX - boundaries.xMin; double optimalMarginY = (topology.getHeight() - (boundaries.yMax - boundaries.yMin)) / 2; double shiftY = optimalMarginY - boundaries.yMin; for(Node node :topology.getNodes()) node.setLocation(node.getX() + shiftX, node.getY() + shiftY, node.getZ()); }  static void autoscale(Topology topology); static void autoscale(Topology topology, AutoScaleParams autoScaleParams); static void center(Topology topology); static TopologyBoundaries computeBoundaries(Topology topology); static void circle(Topology topology, double marginRatio); static void circle(Topology topology); static void ellipse(Topology topology, double xMarginRatio, double yMarginRatio); static void ellipse(Topology topology); static void line(Topology topology, double marginRatio); static void line(Topology topology); static final double DEFAULT_MARGIN; }### Answer:
@Test void center_emptyTopology_ok() { Topology topology = new Topology(); TopologyLayouts.center(topology); Assertions.assertTrue(topology.getNodes().isEmpty()); }
@Test void center_single_centeredPoint() { int width = 200; int height = 300; Topology topology = generateSinglePointTopology(width, height); double zBefore = topology.getNodes().get(0).getZ(); TopologyLayouts.center(topology); checkNodeLocation(topology.getNodes().get(0), width/2.0, height/2.0, zBefore); }
@Test void center_severalOnSamePoint_allCentered() { int width = 200; int height = 300; int nbNodes = 30; Topology topology = generateSeveralPointsOnSameLocationTopology(width, height, nbNodes); double zBefore = topology.getNodes().get(0).getZ(); TopologyLayouts.center(topology); for(int i = 0; i < nbNodes; i++) checkNodeLocation(topology.getNodes().get(i), width/2.0, height/2.0, zBefore); }
@Test void center_minimal_ok() { Topology topology = TestTopology.generateTopology1(); TopologyLayouts.center(topology); TestTopology.assertCenteredDefault1(topology); }