// This sample demonstrates how to connect nodes with links and
  // how to enable collapsing and expanding of tree branches

  // Setting the default property NodesExpandable indicates that all
  // subsequently created nodes will be expandable
  diagram.setNodesExpandable(true);

  // Create two nodes
  ShapeNode parent = diagram.getFactory().createShapeNode(10105020);
  ShapeNode child = diagram.getFactory().createShapeNode(10405020);

  // Connect the nodes by creating a new link
  // from the parent node to the child node
  diagram.getFactory().createDiagramLink(parent, child);