def write_graph(self, output_dir, coin):
     """
 Creates an igraph based on the data collected so far and writes to the output_dir.
 """
     utils.write_network(
         output_dir, coin, self.vertex_names, self.edge_weights, args.directed_network, args.csv_output
     )
Exemple #2
0
 def write_graph(self, output_dir, coin):
     """
 Creates an igraph based on the data collected so far and writes to the output_dir.
 """
     utils.write_network(output_dir, coin, self.vertex_names,
                         self.edge_weights, args.directed_network,
                         args.csv_output)
      # Set the prev_date to the first day in the data.
      if prev_date is None:
        prev_date = datetime.date(date_time.year, date_time.month, date_time.day)

      # only if decay factor is non negative, decay all the edge weights
      new_date = date_time.date() != prev_date
      # Taking snapshots per day or mentioned coin? We will take a snapshot as
      # soon as we observe a new date. This should also happen before we decay the edges
      # for the new date, because the snapshot corresponds to the end of the previous date
      # where the edges did had not decayed yet.
      # Snapshots are taken at the END OF PREVIOUS day. So date 2014-02-02 network
      # represents whatever discussion up to end of 2014-02-01.  Same is true for a coin
      # whose earliest trade in on 2014-02-02, its network only contains interactions up
      # to end of 2014-02-01 (beginning of 2014-02-02).
      if new_date:
        utils.write_network(output_dir, str(date_time.date()), vertex_names,
                            edge_weights, args.directed_network, args.csv_output)
  
        # Now that we took a snapshot of the networks from previous date, we can decay
        # edges.
        if decay_factor > 0:
          utils.decay_edges(edge_weights, decay_factor)
      
      # update the date now that we have checked for new date.
      prev_date = datetime.date(date_time.year, date_time.month, date_time.day)
      
      # Update total activity on subject so far so that we can assign the right edge
      # weight for new contributors in the subject.
      new_subject = full_subject_id not in subject_activity
      subject_activity[full_subject_id] += 1
      
      # add user to graph if not added yet.
Exemple #4
0
                prev_date = datetime.date(date_time.year, date_time.month,
                                          date_time.day)

            # only if decay factor is non negative, decay all the edge weights
            new_date = date_time.date() != prev_date
            # Taking snapshots per day or mentioned coin? We will take a snapshot as
            # soon as we observe a new date. This should also happen before we decay the edges
            # for the new date, because the snapshot corresponds to the end of the previous date
            # where the edges did had not decayed yet.
            # Snapshots are taken at the END OF PREVIOUS day. So date 2014-02-02 network
            # represents whatever discussion up to end of 2014-02-01.  Same is true for a coin
            # whose earliest trade in on 2014-02-02, its network only contains interactions up
            # to end of 2014-02-01 (beginning of 2014-02-02).
            if new_date:
                utils.write_network(output_dir, str(date_time.date()),
                                    vertex_names, edge_weights,
                                    args.directed_network, args.csv_output)

                # Now that we took a snapshot of the networks from previous date, we can decay
                # edges.
                if decay_factor > 0:
                    utils.decay_edges(edge_weights, decay_factor)

            # update the date now that we have checked for new date.
            prev_date = datetime.date(date_time.year, date_time.month,
                                      date_time.day)

            # Update total activity on subject so far so that we can assign the right edge
            # weight for new contributors in the subject.
            new_subject = full_subject_id not in subject_activity
            subject_activity[full_subject_id] += 1