Commit 00e5bf3c authored by Victor Zimmermann's avatar Victor Zimmermann
Browse files

Fixed Zero Division Error. Mankinds greatest challenge resolved with try-except!

parent 8de124b9
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1022,7 +1022,11 @@ def main(topic_id: int, topic_name: str, result_dict: dict) -> None:
        
        edge_count = len(graph.edges)
        node_count = len(graph.nodes)

        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
+5 −1
Original line number Diff line number Diff line
@@ -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,7 +634,11 @@ def main(topic_id: int, topic_name: str, result_dict: dict) -> None:
        
        edge_count = len(graph.edges)
        node_count = len(graph.nodes)

        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