void removeGraphModelConnection(Object obj) {
   GraphConnection connection = (GraphConnection) connectionsMap.get(obj);
   if (connection != null) {
     connectionsMap.remove(obj);
     if (!connection.isDisposed()) {
       connection.dispose();
     }
   }
 }
  /**
   * Removes the given connection object from the layout algorithm and the model.
   *
   * @param connection
   */
  public void removeRelationship(Object connection) {
    GraphConnection relationship = (GraphConnection) connectionsMap.get(connection);

    if (relationship != null) {
      // remove the relationship from the layout algorithm
      if (getLayoutAlgorithm() != null) {
        getLayoutAlgorithm().removeRelationship(relationship.getLayoutRelationship());
      }
      // remove the relationship from the model
      relationship.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();
  }