Example #1
0
 def test_plot_infomap_igraph_show_edges(self,mock_igraph_plot):
     message_graph = util.load_from_disk(current_dir+'/data/message_graph')
     membership = util.load_from_disk(current_dir+'/data/membership')
     igraph = util.load_from_disk(current_dir+'/data/igraph')
     
     # test for infomap generation with edges
     vis.plot_infomap_igraph(message_graph,membership, current_dir, "message", show_edges=True)
     self.assertTrue(mock_igraph_plot.call_args[0][0].isomorphic_vf2(igraph))
Example #2
0
 def test_plot_infomap_igraph_aux_data(self,mock_igraph_plot):
     message_graph = util.load_from_disk(current_dir+'/data/vis/message_exchange_graph')
     membership = util.load_from_disk(current_dir+'/data/vis/message_exchange_graph_membership')
     igraph = util.load_from_disk(current_dir+'/data/vis/message_exchange_igraph')
     aux = util.load_from_disk(current_dir+'/data/vis/aux_data')
     
     # test for infomap generation with auxiliary data
     vis.plot_infomap_igraph(message_graph,membership, current_dir, "message", aux_data = aux)
     self.assertTrue(mock_igraph_plot.call_args[0][0].isomorphic_vf2(igraph))
Example #3
0
 def test_plot_infomap_igraph_no_edges(self,mock_igraph_plot):
     message_graph = util.load_from_disk(current_dir+'/data/message_graph')
     membership = util.load_from_disk(current_dir+'/data/membership')
     igraph = util.load_from_disk(current_dir+'/data/igraph')
     
     # test infomap plotting with edges not shown
     vis.plot_infomap_igraph(message_graph,membership, current_dir, "message", show_edges=False)
     self.assertTrue(mock_igraph_plot.call_args[0][0].isomorphic_vf2(igraph))
     
     # check infomap generation with None membership
     vis.plot_infomap_igraph(message_graph,None, current_dir, "message")
     self.assertTrue(mock_igraph_plot.call_args[0][0].isomorphic_vf2(igraph))
Example #4
0
# ============== OUTPUT ================
saver.save_net_nx_graph (message_number_graph, output_directory, "message_number_graph")
saver.draw_nx_graph(message_number_graph, output_directory, "message_number_graph")

saver.save_csv([["response_time_cutoff"], [rt_cutoff_time]], output_directory, "rt_cutoff")
saver.save_csv([["month", "users", "directed_messages"], ["Jan-2013", len(message_number_graph), int(message_number_graph.size('weight'))]], output_directory, "users_messages")

for dtype in degree_type:
    saver.save_csv(degree_anal_message_number[dtype]["formatted_for_csv"], output_directory, dtype)   

saver.save_csv(bin_matrix, output_directory, "MessageNumber_binsize_"+str(config.BIN_LENGTH_MINS)) 

# =============== VIZ ===================
message_graph, message_comm = community.infomap_igraph(ig_graph=None, net_file_location= output_directory + 'message_number_graph.net')
vis.plot_infomap_igraph(message_graph, message_comm.membership, output_directory, "message")
vis.plot_data (data, output_directory, "bins")

for dtype in degree_type:
    slope,intercept,r_square,mse = vis.generate_log_plots(degree_anal_message_number[dtype]["raw_for_vis"], output_directory, channel_name[0] +dtype)
    saver.save_csv( [["Y","K","R^2", "MSE"], [slope,intercept,r_square,mse]], output_directory, dtype+"-curve-fit")

# ============== PRESENCE ACROSS MULTIPLE CHANNELS ==============
# Change analysis to all channels in config
log_data = reader.linux_input(log_directory, ["ALL"], starting_date, ending_date)
nicks, nick_same_list, channels_for_user, nick_channel_dict, nicks_hash, channels_hash = nickTracker.nick_tracker(log_data, True)
dict_out, graph = network.channel_user_presence_graph_and_csv(nicks, nick_same_list, channels_for_user, nick_channel_dict, nicks_hash, channels_hash)

saver.save_js_arc(dict_out["CC"]["reducedGraph"], channels_hash, config.OUTPUT_DIRECTORY + "protovis/", "cc.js")

for ptype in presence_type:
Example #5
0
            ig_graph=None,
            net_file_location=output_directory + "message-exchange-" +
            starting_date + "-cutoff-" + str(cutoff) + '.net')

        if cutoff != 0:
            # be careful; vis.plot_infomap_igraph() takes a long time to complete on large graphs
            print("vis.plot_infomap_igraph() starts for",
                  starting_date,
                  "with cutoff=",
                  cutoff,
                  "at: ",
                  datetime.datetime.now(),
                  file=exec_times_file)
            exec_times_file.flush()
            vis.plot_infomap_igraph(
                msg_graph, message_community.membership, output_directory,
                "message-exchange-" + starting_date + "-cutoff-" + str(cutoff))
            print("vis.plot_infomap_igraph() ends for",
                  starting_date,
                  "with cutoff=",
                  cutoff,
                  "at: ",
                  datetime.datetime.now(),
                  file=exec_times_file)
            exec_times_file.flush()

        del msg_graph, message_community
        gc.collect()
        print("dynamic community analysis for",
              starting_date,
              "with cutoff=",