diff --git a/src/absinth.py b/src/absinth.py index 1c527ff87cdfeac6d2be72ce36bad9eb822cfe9c..e777ccf267d9c3cc4f9a9ff1e155d5ef8dd10b75 100644 --- a/src/absinth.py +++ b/src/absinth.py @@ -151,7 +151,7 @@ def induce(topic_name: str, result_list: list) -> (nx.Graph, list, dict): edge_freq_dict = {(key1,key2):value2 for key1,value1 in edge_freq_dict.items() for key2,value2 in value1.items()} print('[a] Collected frequencies from secret hideout.') - + continue if graph_in_existence == False: @@ -1022,8 +1022,12 @@ def main(topic_id: int, topic_name: str, result_dict: dict) -> None: edge_count = len(graph.edges) node_count = len(graph.nodes) - mean_degree = edge_count/node_count - + + try: + mean_degree = edge_count/node_count + except ZeroDivisionError: + mean_degree = 0 + stat_dict['L_rand'] = np.log(node_count)/np.log(mean_degree) stat_dict['C_rand'] = 2 * mean_degree/node_count diff --git a/src/abstinent.py b/src/abstinent.py index e4aa17079f02e8f019e6b668d14352738ceaec3e..5536301951ed8adecfba1b54111bafb0286291a4 100644 --- a/src/abstinent.py +++ b/src/abstinent.py @@ -368,7 +368,7 @@ def induce(topic_name: str, result_list: list) -> (nx.Graph, list, dict): edge_freq_dict = {(key1,key2):value2 for key1,value1 in edge_freq_dict.items() for key2,value2 in value1.items()} - print('[a] Collected frequencies from hidden hideout.') + print('[a] Collected frequencies from secret hideout.') continue @@ -634,8 +634,12 @@ def main(topic_id: int, topic_name: str, result_dict: dict) -> None: edge_count = len(graph.edges) node_count = len(graph.nodes) - mean_degree = edge_count/node_count - + + try: + mean_degree = edge_count/node_count + except ZeroDivisionError: + mean_degree = 0 + stat_dict['L_rand'] = np.log(node_count)/np.log(mean_degree) stat_dict['C_rand'] = 2 * mean_degree/node_count