public Edge getFirstEdgeAtPosition(int x, int y, Node n) {
		for(Edge e : n.outgoingConnections) {
			if(e.isInside(x, y, pt)) {
				Edge opposEdge = e.getOppositeEdge();
				if(opposEdge != null){
					//find out which one we want to delete.
					pt.translateToGUIPosition(e.endNode.getPosition());
					Position oneEnd = new Position(pt.guiXDouble, pt.guiYDouble, 0.0);
					pt.translateToGUIPosition(opposEdge.endNode.getPosition());
					Position otherEnd = new Position(pt.guiXDouble, pt.guiYDouble, 0.0);
					Position eventPos = new Position(x, y, 0.0);
					
					if(eventPos.distanceTo(oneEnd) > eventPos.distanceTo(otherEnd)){
						return opposEdge;
					}	else {
						return e;
					}
				} else { // there is no opposite edge, return e
					return e;
				}
			}
		}
		return null;
	}