                 node: node
                 port: port
         @initializers.push initializer
-        @emit "addEdge", initializer
+        @emit 'addEdge', initializer
 
     toDOT: ->
         cleanID = (id) ->

fs = require "fs"
events = require "events"
fbp = require "./Fbp"

class Graph extends events.EventEmitter
    name: ""
    nodes: []
    edges: []
    initializers: []

    constructor: (name) ->
        @nodes = []
        @edges = []
        @initializers = []
        @name = name

    addNode: (id, component, display) ->
        node =
            id: id
            component: component
            display: display
        @nodes.push node
        @emit "addNode", node

    removeNode: (id) ->
        node =
            id: id

                node: inNode
                port: inPort
        @edges.push edge
        @emit 'addEdge', edge

    # ## Disconnected nodes
    #
    # Connections between nodes can be removed by providing the
    # node and port to disconnect. The specified node and port can
    # be either the outport or the inport of the connection:
    #
    #     myGraph.removeEdge 'Read', 'out'
    #
    # or:
    # 
    #     myGraph.removeEdge 'Display', 'in'
    #
    # Removing a connection will emit the `removeEdge` event.
    removeEdge: (node, port) ->
        for edge,index in @edges
            if edge.from.node is node and edge.from.port is port
                @emit 'removeEdge', edge
                @edges.splice index, 1
            if edge.to.node is node and edge.to.port is port
                @emit 'removeEdge', edge
                @edges.splice index, 1

        for edge,index in @initializers
            if edge.to.node is node and edge.to.port is port
                @emit 'removeEdge', edge
                @initializers.splice index, 1

    # ## Adding Initial Information Packets
    #
    # Initial Information Packets (IIPs) can be used for sending data
    # to specified node inports without a sending node instance.
    #
    # IIPs are especially useful for sending configuration information
    # to components at NoFlo network start-up time. This could include
    # filenames to read, or network ports to listen to.
    #
    #     myGraph.addInitial 'somefile.txt', 'Read', 'source'
    #
    # Adding an IIP will emit a `addEdge` event.
    addInitial: (data, node, port) ->
        initializer =
            from:
