// This sample demonstrates how to find paths in a graph

    // Make sure there are at least two nodes in the diagram
    if (diagram.getNodes().size() 2)
      return;

    // Use the PathFinder class to find paths and cycles in a graph
    Path path = PathFinder.findShortestPath(diagram,
      diagram.getNodes().get(0),
      diagram.getNodes().get(diagram.getNodes().size() 1));

    // If the returned reference is null, no path has been found
    if (path == null)
    {
      JOptionPane.showMessageDialog(null, "No path found!");
      return;
    }

    // Color the path
    for (DiagramNode n : path.getNodes())
    {
      n.setBrush(new SolidBrush(Color.YELLOW));
      n.setPen(new Pen(1, Color.RED));
    }

    for (DiagramLink link : path.getLinks())
      link.setPen(new Pen(1, Color.RED));