 
   onGraphChanged: (data)->
     @nodes = data.nodes
-
-    simulator = new Simulation
-      nodes: @nodes
-      newIntegration: @settings.newIntegration
-
-    @graphIsValid = simulator.graphIsValid()
+    @_updateGraphValid()
     @notifyChange()
 
   onSetDuration: (n) ->

      @currentSimulation.stop()
    @settings.modelReadyToRun = true
    @notifyChange()

  _checkModelIsRunnable: ->
    @settings.modelIsRunnable = @graphIsValid and @settings.duration > 0


  onSetNewIntegration: (newInt) ->
    @settings.newIntegration = newInt
    @_updateGraphValid()
    @notifyChange()

  onRunSimulation: ->
    if @settings.modelIsRunnable and @settings.modelReadyToRun
      @currentSimulation = new Simulation
