public void mouseReleased( MouseEvent e ) {

        Node mouseOverN = tgPanel.getMouseOverN();



        if (mouseOverN!=null && dragAddNode!=null && mouseOverN!=dragAddNode) {

            Edge ed=tgPanel.findEdge(dragAddNode,mouseOverN);

            if (ed==null) tgPanel.addEdge(dragAddNode,mouseOverN, Edge.DEFAULT_LENGTH); 

            else tgPanel.deleteEdge(ed);



        } else if ( mouseOverN == null && dragAddNode != null ) {

            try {

                Node n =tgPanel.addNode(); 

                tgPanel.addEdge(dragAddNode,n, Edge.DEFAULT_LENGTH); 

                n.drawx = tgPanel.getMousePos().x; 

                n.drawy = tgPanel.getMousePos().y;

                tgPanel.updatePosFromDraw(n); 

            } catch ( TGException tge ) {

                System.err.println(tge.getMessage());

                tge.printStackTrace(System.err);

            }

        }



        if (mouseWasDragged) { //Don't reset the damper on a mouseClicked

            tgPanel.resetDamper();

            tgPanel.startDamper();

        }   



        dragAddNode=null;

    }