    # File lib/graphviz/theory.rb, line 28
        def incidence_matrix
          tail = (@graph.type == "digraph") ? -1 : 1
          matrix = GraphViz::Math::Matrix.new( @graph.node_count, @graph.edge_count )

          @graph.each_edge { |e|
            x = e.index

            nstart = @graph.get_node(e.node_one( false )).index
            nend = @graph.get_node(e.node_two( false )).index

            matrix[nstart+1, x+1] = 1
            matrix[nend+1, x+1] = tail
            matrix[nend+1, x+1] = 2 if nstart == nend
          }

          return matrix
        end