Ejemplo n.º 1
0
    def write_edges(self, fh, edge_func):
        c = SSCursor(self.dbh)
        _start = time.time()

        c.execute(self.edges_query)

        # write the header:
        fh.write("*Arcs\r\n")

        # I need some duplicate protection

        count = 0
        res = c.fetchone()
        while (res):
            (_to, _from, _weight) = res
            count += 1
            # could call external func here
            fh.write("%s %s %f\r\n" % (self.map[_to], self.map[_from],
                                       (_weight or 1)))
            if (count % 1000 == 0):
                sys.stdout.write('.')
                sys.stdout.flush()

            # get next record
            res = c.fetchone()

        # end this function
        c.close()
        print "\nWrote %i Edges in %f\n" % (count, time.time() - _start)
Ejemplo n.º 2
0
  def write_edges(self, fh, edge_func):
    c = SSCursor(self.dbh)
    _start = time.time()

    c.execute(self.edges_query)

    # write the header:
    fh.write("*Arcs\r\n")
    
    # I need some duplicate protection

    count = 0
    res = c.fetchone()
    while( res):
      (_to, _from, _weight) = res
      count +=1
      # could call external func here
      fh.write("%s %s %f\r\n" %(self.map[_to], self.map[_from], (_weight or 1)))
      if(count % 1000 == 0):
        sys.stdout.write('.')        
        sys.stdout.flush()
      
      # get next record
      res = c.fetchone()
      
    # end this function
    c.close()
    print "\nWrote %i Edges in %f\n" %(count, time.time() - _start)
Ejemplo n.º 3
0
  def write_edges(self, fh, edge_func):
    c = SSCursor(self.dbh)
    _start = time.time()

    c.execute(self.edges_query)

    # write the header:
    fh.write("*Edges\r\n")
    
    # I need some duplicate protection
    count = 0
    res = c.fetchone()
    while( res):
      (_to, _from, _weight) = res
      count +=1
      
      # check it:
      min = _to
      max = _from

      if(min > max):
        min = _from
        max = _to

      if(self._biglist.matrix[min][max] == 1):
        res = c.fetchone()
        continue
      else:
        self._biglist.matrix[min][max] = 1

      # could call external func here
      fh.write("%s %s %f\r\n" %(self.map[_to], self.map[_from], (_weight or 1)))
      if(count % 50 == 0):
        sys.stdout.write('.')        
        sys.stdout.flush()
      
      # get next record
      res = c.fetchone()
      
    # end this function
    c.close()
    print "\nWrote %i Edges in %f\n" %(count, time.time() - _start)