# Path: lib/analysis/network.py
# def message_number_graph(log_dict, nicks, nick_same_list, DAY_BY_DAY_ANALYSIS=False):
#     def msg_no_analysis_helper(rec_list, corrected_nick, nick, conn_comp_list,conversations,today_conversation):
#     def message_no_add_egde(message_graph, conversation):
# def channel_user_presence_graph_and_csv(nicks, nick_same_list, channels_for_user, nick_channel_dict, nicks_hash, channels_hash):
#     def create_adj_matrix(hashed_list1, hashed_list2):
#     def add_channel_weighted_edge(graph, adjlist, nicks_hash, channels_hash, channel):
#     def add_common_users_weighted_edge(graph, index1, index2, common_users):
#     def print_node_degree(nodes, max_degree_possible):
#     def inc_degree(degree_list, nodes, max_degree_possible):        
#     def get_top_indices(sum_list, how_many_vals):        
#     def get_indices_to_delete(hash_list, top_indices):
# def filter_edge_list(edgelist_file_loc, max_hash, how_many_top):
# def degree_analysis_on_graph(nx_graph, date=None, directed = True):
#     def nodes_with_degree_populator(degree_values, label): 
#     def give_userlist_where_degree_helper(degree_dict, degree):
#     def raw_node_append(nodes, raw, degree_type):        
# def message_time_graph(log_dict, nicks, nick_same_list, DAY_BY_DAY_ANALYSIS=False):
#     def compare_spliced_nick(nick_to_compare, spliced_nick, nick_name, line):
# def message_number_bins_csv(log_dict, nicks, nick_same_list):
#     def bin_increment(nick_name, messager, nick_spliced, bins, bin_index):
# def degree_node_number_csv(log_dict, nicks, nick_same_list):
#     def format_degree_list(degree_list, max_range, degree_type):
# def nick_receiver_from_conn_comp(nick, conn_comp_list):
# def identify_hubs_and_experts(log_dict, nicks, nick_same_list):
#     G = util.to_graph(nick_same_list)
#     G = util.to_graph(nick_same_list)
# 
# Path: lib/analysis/channel.py
# def conv_len_conv_refr_time(log_dict, nicks, nick_same_list, rt_cutoff_time, cutoff_percentile):
#     def build_conversation(rec_list, nick, send_time, nick_to_search,
#                            nick_receiver, nick_sender, dateadd,
#                            conversations, conn_comp_list, line):
#     def conv_helper(rec, nick, send_time, nick_to_search, nick_receiver,
#                     nick_sender, dateadd, conversations, conn_comp_list, line):
#     def conv_mat_diff(i,j,conversations):
#     def conv_append(conversations, index, dateadd, line):
#     def parse_log_lines_for_conv(log_dict, nicks, conn_comp_list, conversations):
# def response_time(log_dict, nicks, nick_same_list, cutoff_percentile):
#     def build_mean_list(conversations, index, mean_list):
#     def resp_helper(rec, nick, send_time, nick_to_search, nick_receiver, nick_sender, conversations, conn_comp_list):
# def build_stat_dist(number_list):
# def truncate_table(table, cutoff_percentile):
#     G = util.to_graph(nick_same_list)
#     G = util.to_graph(nick_same_list)
# 
# Path: lib/analysis/user.py
# def nick_change_graph(log_dict, DAY_BY_DAY_ANALYSIS=False):
# def top_keywords_for_nick(user_keyword_freq_dict, nick, threshold, min_words_spoken):
# def keywords(log_dict, nicks, nick_same_list):
#     def get_nick_receiver(nick_receiver, rec, nick_to_compare, nick_name, nicks, nick_same_list):
# def keywords_clusters(log_dict, nicks, nick_same_list, output_directory, out_file_name):
#     def build_centroid(km):
# def extended_stop_words(nicks_for_stop_words, stop_word_without_apostrophe):
# 
# Path: lib/analysis/community.py
# def infomap_igraph(ig_graph, net_file_location=None):
# 
# Path: lib/in_out/reader.py
# def linux_input(log_directory, channels_requested, starting_date, ending_date):
#     def check_if_path_and_file_is_valid(work_path, channels_requested):
# 
# Path: lib/in_out/saver.py
# def check_if_dir_exists(output_directory):
# def draw_nx_graph(nx_graph, output_directory, output_file_name):
# def save_net_nx_graph(nx_graph, output_directory, output_file_name):
# def save_csv(matrix, output_directory, output_file_name):
# def save_js_arc(reduced_CC_graph, channels_hash, output_directory, output_file_name):
#     A = nx.nx.drawing.nx_agraph.to_agraph(nx_graph)


import lib.config as config
import lib.nickTracker as nickTracker
import lib.validate as validate
import lib.vis as vis
from lib.analysis import network, channel, user, community
from lib.in_out import reader, saver

log_directory = config.LOG_DIRECTORY
channel_name = config.CHANNEL_NAME
starting_date = config.STARTING_DATE
ending_date = config.ENDING_DATE
output_directory = config.OUTPUT_DIRECTORY

degree_type = ["out_degree", "in_degree", "total_degree"]
presence_type = ["CC", "UU", "CU"]

# ============== INPUT==================
log_data = reader.linux_input(log_directory, channel_name, starting_date, ending_date)
nicks, nick_same_list = nickTracker.nick_tracker(log_data)

# ============== ANALYSIS =============

# Path: lib/analysis/network.py
# def message_number_graph(log_dict, nicks, nick_same_list, DAY_BY_DAY_ANALYSIS=False):
#     def msg_no_analysis_helper(rec_list, corrected_nick, nick, conn_comp_list,conversations,today_conversation):
#     def message_no_add_egde(message_graph, conversation):
# def channel_user_presence_graph_and_csv(nicks, nick_same_list, channels_for_user, nick_channel_dict, nicks_hash, channels_hash):
#     def create_adj_matrix(hashed_list1, hashed_list2):
#     def add_channel_weighted_edge(graph, adjlist, nicks_hash, channels_hash, channel):
#     def add_common_users_weighted_edge(graph, index1, index2, common_users):
#     def print_node_degree(nodes, max_degree_possible):
#     def inc_degree(degree_list, nodes, max_degree_possible):        
#     def get_top_indices(sum_list, how_many_vals):        
#     def get_indices_to_delete(hash_list, top_indices):
# def filter_edge_list(edgelist_file_loc, max_hash, how_many_top):
# def degree_analysis_on_graph(nx_graph, date=None, directed = True):
#     def nodes_with_degree_populator(degree_values, label): 
#     def give_userlist_where_degree_helper(degree_dict, degree):
#     def raw_node_append(nodes, raw, degree_type):        
# def message_time_graph(log_dict, nicks, nick_same_list, DAY_BY_DAY_ANALYSIS=False):
#     def compare_spliced_nick(nick_to_compare, spliced_nick, nick_name, line):
# def message_number_bins_csv(log_dict, nicks, nick_same_list):
#     def bin_increment(nick_name, messager, nick_spliced, bins, bin_index):
# def degree_node_number_csv(log_dict, nicks, nick_same_list):
#     def format_degree_list(degree_list, max_range, degree_type):
# def nick_receiver_from_conn_comp(nick, conn_comp_list):
# def identify_hubs_and_experts(log_dict, nicks, nick_same_list):
#     G = util.to_graph(nick_same_list)
#     G = util.to_graph(nick_same_list)
# 
# Path: lib/analysis/channel.py
# def conv_len_conv_refr_time(log_dict, nicks, nick_same_list, rt_cutoff_time, cutoff_percentile):
#     def build_conversation(rec_list, nick, send_time, nick_to_search,
#                            nick_receiver, nick_sender, dateadd,
#                            conversations, conn_comp_list, line):
#     def conv_helper(rec, nick, send_time, nick_to_search, nick_receiver,
#                     nick_sender, dateadd, conversations, conn_comp_list, line):
#     def conv_mat_diff(i,j,conversations):
#     def conv_append(conversations, index, dateadd, line):
#     def parse_log_lines_for_conv(log_dict, nicks, conn_comp_list, conversations):
# def response_time(log_dict, nicks, nick_same_list, cutoff_percentile):
#     def build_mean_list(conversations, index, mean_list):
#     def resp_helper(rec, nick, send_time, nick_to_search, nick_receiver, nick_sender, conversations, conn_comp_list):
# def build_stat_dist(number_list):
# def truncate_table(table, cutoff_percentile):
#     G = util.to_graph(nick_same_list)
#     G = util.to_graph(nick_same_list)
# 
# Path: lib/analysis/user.py
# def nick_change_graph(log_dict, DAY_BY_DAY_ANALYSIS=False):
# def top_keywords_for_nick(user_keyword_freq_dict, nick, threshold, min_words_spoken):
# def keywords(log_dict, nicks, nick_same_list):
#     def get_nick_receiver(nick_receiver, rec, nick_to_compare, nick_name, nicks, nick_same_list):
# def keywords_clusters(log_dict, nicks, nick_same_list, output_directory, out_file_name):
#     def build_centroid(km):
# def extended_stop_words(nicks_for_stop_words, stop_word_without_apostrophe):
# 
# Path: lib/analysis/community.py
# def infomap_igraph(ig_graph, net_file_location=None):
# 
# Path: lib/in_out/reader.py
# def linux_input(log_directory, channels_requested, starting_date, ending_date):
#     def check_if_path_and_file_is_valid(work_path, channels_requested):
# 
# Path: lib/in_out/saver.py
# def check_if_dir_exists(output_directory):
# def draw_nx_graph(nx_graph, output_directory, output_file_name):
# def save_net_nx_graph(nx_graph, output_directory, output_file_name):
# def save_csv(matrix, output_directory, output_file_name):
# def save_js_arc(reduced_CC_graph, channels_hash, output_directory, output_file_name):
#     A = nx.nx.drawing.nx_agraph.to_agraph(nx_graph)


# Path: ubuntu.py
import lib.config as config
import lib.nickTracker as nickTracker
import lib.validate as validate
import lib.vis as vis
from lib.analysis import network, channel, user, community
from lib.in_out import reader, saver


log_directory = config.LOG_DIRECTORY
channel_name = config.CHANNEL_NAME
starting_date = config.STARTING_DATE
ending_date = config.ENDING_DATE
output_directory = config.OUTPUT_DIRECTORY

degree_type = ["out_degree", "in_degree", "total_degree"]
presence_type = ["CC", "UU", "CU"]

# ============== INPUT==================
log_data = reader.linux_input(log_directory, channel_name, starting_date, ending_date)
nicks, nick_same_list = nickTracker.nick_tracker(log_data)

# ============== ANALYSIS =============

message_number_graph = network.message_number_graph(log_data, nicks, nick_same_list, False)