         fill: 'white',
         stroke: 'black',
         strokeWidth: 1.5,
-        fillOpacity: 1
+        fillOpacity: 1,
+        draggable: true
       },
       edges: {
         stroke: 'black',

      des
    )
    @edges.push(e)

  fetchNode: (id)->
    @nodes.find (node)->
      node.id == id

class SvgNodes.Responsible
  constructor: ->
    @svg.click ->
      for fn in @_clickHandlers
        fn()
    @svg.drag ->
      for fn in @_dragHandlers
        fn()

  onClick: (fn)->
    @_clickHandlers.push(fn)

  onDrag:  (fn)->
    @_dragHandlers.push(fn)

class SvgNodes.Node extends SvgNodes.Responsible
  constructor: (@map, @id, @x, @y, @r, @text, @style)->

    @svg = @map.svg.circle(@x, @y, @r)
    @label = new SvgNodes.Label(@map, @x + @r, @y + @r, @text)
    @svg.attr(@map.options.nodes)
    this.setDraggable(@map) if @map.options.nodes.draggable

  setDraggable: (map, draggable = true) =>
    return unless draggable
    node = this
    this.svg.drag (dx, dy, x, y, e)=>
      x = x - map.bbox.x
      y = y - map.bbox.y
      this.move(x,y)

  move: (x, y)=>
    @x = x
    @y = y
    this.attr
      cx: @x
      cy: @y
    this._moveEdges()
    this._moveLabel()

  _moveEdges: =>
    @map.edges.forEach (e)=>
      if e.src.id == @id
        e.svg.attr
          x1: @x
          y1: @y
      if e.dest.id == @id
        e.svg.attr
          x2: @x
          y2: @y
  _moveLabel: =>
    @label.svg.attr
      x: @x + @r
      y: @y + @r

  attr: (hash)->
    @svg.attr(hash)
