     @restart()
     @clearSelection()
 
-  removeRelatedEdges : (d) =>
+  removeRelatedEdges : (node_dict) =>
     me = @
     to_remove = @link_data.filter (l) ->
-      l.source == d || l.target == d
+      l.source == node_dict || l.target == node_dict
     to_remove.map (l) ->
       me.link_data.splice(me.link_data.indexOf(l), 1)
 
     @restart()
-
 
   renderToolbar: () =>
     @TOOLBAR.html(@toolbarTemplate())
     @TOOLBAR.find('.graphedit-toolbar-zoomin').on('click', @zoomIn)
     @TOOLBAR.find('.graphedit-toolbar-zoomout').on('click', @zoomOut)
-    @TOOLBAR.find('.graphedit-toolbar-remove').on('click', @remove)
+    @TOOLBAR.find('.graphedit-toolbar-remove').on('click', @removeSelection)
     @TOOLBAR.find('.graphedit-toolbar-new-edge').on('click', @newEdge)
     @TOOLBAR.find('.graphedit-toolbar-new-node').on('click', @newNode)
 

    @links.attr "y1", (d) -> d.source.y
    @links.attr "x2", (d) -> d.target.x
    @links.attr "y2", (d) -> d.target.y

  # clear the selection
  clearSelection : () ->


      @addEdge({"src":src.node_id, "dest":dest.node_id})


  #allow node inserts from front end
  _idSeq : 0
  newNode: () =>
    @addNode({node_id:"new-" + @_idSeq++})

