void removeGraphModelNode(Object obj) {
   GraphNode node = (GraphNode) nodesMap.get(obj);
   if (node != null) {
     nodesMap.remove(obj);
     if (!node.isDisposed()) {
       node.dispose();
     }
   }
 }
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.jface.viewers.Viewer#inputChanged(java.lang.Object,
   *      java.lang.Object)
   */
  protected void inputChanged(Object input, Object oldInput) {
    IStylingGraphModelFactory factory = getFactory();
    factory.setConnectionStyle(getConnectionStyle());
    factory.setNodeStyle(getNodeStyle());

    // Save the old map so we can set the size and position of any nodes
    // that are the same
    Map oldNodesMap = nodesMap;
    Graph graph = (Graph) getControl();
    graph.setSelection(new GraphNode[0]);

    Iterator iterator = nodesMap.values().iterator();
    while (iterator.hasNext()) {
      GraphNode node = (GraphNode) iterator.next();
      if (!node.isDisposed()) {
        node.dispose();
      }
    }

    iterator = connectionsMap.values().iterator();
    while (iterator.hasNext()) {
      GraphConnection connection = (GraphConnection) iterator.next();
      if (!connection.isDisposed()) {
        connection.dispose();
      }
    }

    nodesMap = new HashMap();
    connectionsMap = new HashMap();

    graph = factory.createGraphModel(graph);

    ((Graph) getControl()).setNodeStyle(getNodeStyle());
    ((Graph) getControl()).setConnectionStyle(getConnectionStyle());

    // check if any of the pre-existing nodes are still present
    // in this case we want them to keep the same location & size
    for (Iterator iter = oldNodesMap.keySet().iterator(); iter.hasNext(); ) {
      Object data = iter.next();
      GraphNode newNode = (GraphNode) nodesMap.get(data);
      if (newNode != null) {
        GraphNode oldNode = (GraphNode) oldNodesMap.get(data);
        newNode.setLocation(oldNode.getLocation().x, oldNode.getLocation().y);
        if (oldNode.isSizeFixed()) {
          newNode.setSize(oldNode.getSize().width, oldNode.getSize().height);
        }
      }
    }

    applyLayout();
  }
  /**
   * Removes the given element from the layout algorithm and the model.
   *
   * @param element The node element to remove.
   */
  public void removeNode(Object element) {
    GraphNode node = (GraphNode) nodesMap.get(element);

    if (node != null) {
      // remove the node from the layout algorithm and all the connections
      if (getLayoutAlgorithm() != null) {
        getLayoutAlgorithm().removeEntity(node.getLayoutEntity());
        getLayoutAlgorithm().removeRelationships(node.getSourceConnections());
        getLayoutAlgorithm().removeRelationships(node.getTargetConnections());
      }
      // remove the node and it's connections from the model
      node.dispose();
    }
  }