// This sample demonstrates how to
  // apply spring layout to a graph

  // Create the layout object
  SpringLayout layout = new SpringLayout();

  // Adjust the attributes of the layout
  layout.setIterations(100);
  layout.setMinimizeCrossings(true);

  // Perform the actual arrangement
  layout.arrange(diagram);