public void mouseDragged(Point p) {
    //System.out.println("mousedragged");
    //insert location mode
    if(mode==INSERTLOC){
      if(curr!=-1){
        mygraph.locations[curr].setPoint(p);
        changeNotify();
      }
    }
    //insert path mode
    if(mode==INSERTPATH){
      lineEndIndex=mygraph.findIndex(p);
      if((lineStartIndex!=-1)&&(lineEndIndex!=-1)&&lineStartIndex!=lineEndIndex){
        mygraph.setEdge(lineStartIndex,lineEndIndex);
        changeNotify();
        lineStartIndex=-1;
        lineEndIndex=-1;
      }
    }
  }