     find_arc: (val) ->
       for arc in @_arcs
         return arc if arc.test(val)
-
-    intersect: (other) ->
-      # warning: Cartesian product
-      arc for arc in @arcs() when other.find_arc(arc.value)
 
   class @Arc
     constructor: (@vertex, @id, @value, @next_vertex) ->

          next.push(arc.next_vertex)
      return next


  traverse: (callback) ->
    _traverse = @stepper()
    next = _traverse([@source], callback)
    while next.length > 0
      next = _traverse(next, callback)

  write_graph: (filename) ->
    fs = require("fs")
    string = Graphviz.digraph_preamble("Djinn")

    while (next_vertices = helper.get_next_vertices())
      [this_vertex, other_vertex, product_vertex] = next_vertices

      # for the two current vertices, iterate over the arcs with same values.
      # TODO: check the arc intersection algorithm for stupids.
      helper.intersecting_arcs this_vertex, other_vertex, (this_arc, other_arc) ->
        this_next = this_arc.next_vertex
        other_next = other_arc.next_vertex

        # if the new graph does not already have the intersection state,
        # create an intersection state and index it
        product_next = helper.product_vertex(this_next, other_next)
        product.add_arc(product_vertex, product_next, this_arc.value)
    product


  traverse: (callback) ->
    _traverse = @stepper()
    next = _traverse([@source], callback)
    while next.length > 0
      next = _traverse(next, callback)

  stepper: ->
    visited_arcs = {}
