 				d3.select(this).attr 'transform', '' # unenlarge target node
 
 			.on 'mousedown', (node) ->
+				# select node
+				mouseDownNode = node
+				if mouseDownNode == selectedNode
+					selectedNode = null
+				else
+					selectedNode = mouseDownNode
+
 				# reposition drag line
 				drag_line.style('marker-end', 'url(#endArrow)').classed('hidden', false).attr('d', 'M' + mouseDownNode.x + ',' + mouseDownNode.y + 'L' + mouseDownNode.x + ',' + mouseDownNode.y)
 				restart()

				.style('marker-end', (edge) -> if edge.right then 'url(#endArrow)' else '')
				.on 'mousedown', (edge) ->
					mouseDownEdge = edge
					restart()

			# remove old links

						net.addEdge(edge)
						$scope.$apply() # Quick save net to storage

				selectedNode = null
				restart()

			# show node text
