       @inPorts.add targetPortName, port
       @inPorts[targetPortName].once 'connect', =>
         # Start the network implicitly if we're starting to get data
+        return if @starting
         return if @isStarted()
-        do @start
+        @start ->
 
     for portName, port of outPorts
       targetPortName = @isExportedOutport port, name, portName

          notReady = true unless @checkComponent name, node
        do @setToReady unless notReady
    , true

  start: (callback) ->
    unless callback
      callback = ->
    return callback() if @started
    unless @isReady()
      @on 'ready', =>
        @start callback
      return
    super()
    return callback null unless @network
    @network.start (err) ->
      return callback err if err
      do callback

  checkComponent: (name, process) ->
    unless process.component.isReady()

  isSubgraph: ->
    true

  setUp: (callback) ->
    @starting = true
    unless @isReady()
      @once 'ready', =>
        @setUp callback
      return
    return callback null unless @network
    @network.start (err) ->
      return callback err if err
      @starting = false
      do callback

  tearDown: (callback) ->
    @starting = false
    return callback null unless @network
    @network.stop (err) ->
      return callback err if err
      do callback

exports.getComponent = (metadata) -> new Graph metadata
