def add_post(self, full_subject_id, user, started_by): """ Adds or updates the edge depending on the network type: 1- In directed network, adds or update directed edge from user (poster in the thread) to started_by (originator of the thread). The idea is that a directed edge to originator grants him influence and power. 2 - In undirected graph, adds or updates edge from user to all previous contributors of the thread. """ # Update total activity on subject so far so that we can assign the right edge weight # for new contributors in the subject. self.subject_activity[full_subject_id] += 1 # add user to graph if not added yet. self.vertex_names.add(user) # Increase the weight or add an edge between this contributor and the # user who originated the thread (directed) or other contributors (undirected). # from the contributor to the starter of the thread. # Update only if this contributor is new in the subject. Weights are updated # according to thread activity. utils.update_edge_weights( user, started_by, args.directed_network, args.weigh_thread, self.subject_activity[full_subject_id], self.subject_contributors[full_subject_id], self.edge_weights, ) # add user to the post contributors (self.subject_contributors[full_subject_id]).add(user)
def add_post(self, full_subject_id, user, started_by): """ Adds or updates the edge depending on the network type: 1- In directed network, adds or update directed edge from user (poster in the thread) to started_by (originator of the thread). The idea is that a directed edge to originator grants him influence and power. 2 - In undirected graph, adds or updates edge from user to all previous contributors of the thread. """ # Update total activity on subject so far so that we can assign the right edge weight # for new contributors in the subject. self.subject_activity[full_subject_id] += 1 # add user to graph if not added yet. self.vertex_names.add(user) # Increase the weight or add an edge between this contributor and the # user who originated the thread (directed) or other contributors (undirected). # from the contributor to the starter of the thread. # Update only if this contributor is new in the subject. Weights are updated # according to thread activity. utils.update_edge_weights(user, started_by, args.directed_network, args.weigh_thread, self.subject_activity[full_subject_id], self.subject_contributors[full_subject_id], self.edge_weights) # add user to the post contributors (self.subject_contributors[full_subject_id]).add(user)
# 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. vertex_names.add(user) utils.update_edge_weights(user, started_by, args.directed_network, args.weigh_thread, subject_activity[full_subject_id], subject_contributors[full_subject_id], edge_weights) # add user to the post contributors (subject_contributors[full_subject_id]).add(user)