code: import datetime
  import sys
  import time
  import os
  
  from ClusterGivenGraph.Graph import Graph
  from ClusterGivenGraph.GraphHelper import get_graph_based_degree_sequence, create_motifs, export_to_pajek, \
      motifs_main_calculation, calc_z_score, export_to_pajek_by_z_score
  import networkx as nx
  from matplotlib import pyplot as plt
  import statistics
  
  glob_i = 0
  glob_itrs = 0
  glob_req_time = ''
  
  
  def print_progress_bar(prefix='', suffix='', decimals=1, length=50, fill='█'):
      global glob_i
      glob_i = glob_i + 1
      percent = ("{0:." + str(decimals) + "f}").format(100 * (glob_i / float(glob_itrs)))
      filled_length = int(length * glob_i // glob_itrs)
      bar = fill * filled_length + '-' * (length - filled_length)
      print('\r%s |%s| %s%% %s ' % (prefix, bar, percent, suffix), end='\r')
      # Print New Line on Complete
      if glob_i == glob_itrs:
          print()
  
  
  def start_here(node_cnt, p_val, edge_cnt, init_scale, tmp_uid):
      # print("------------------- Started A New Iteration " + str(tmp_uid) + " ---------------------")
      file_location = './Output/' + str(tmp_uid) + "/"
      if not os.path.exists(file_location):
          os.makedirs(file_location)
          print_progress_bar()  # print("Create Scale-free Graph")
  
      st_graph_obj = Graph(n=node_cnt, p=p_val, e=edge_cnt, init_scale=init_scale)
      st_graph_obj.create_scale_free_graph()
      st_nx_graph = st_graph_obj.get_graph()
  
      print_progress_bar()  # print("Create Random Graph")
  
      nd_graph_obj = Graph(n=node_cnt, p=p_val, e=len(st_nx_graph.edges))
      nd_graph_obj.create_random_graph()
      nd_nx_graph = nd_graph_obj.get_graph()
  
      print_progress_bar()  # print("Join Both Graph")
  
      rd_nx_graph = st_graph_obj.compose_graph(nd_nx_graph)
  
      rd_nx_degree_sequence = [d for n, d in rd_nx_graph.degree()]
  
      th_nx_graph = get_graph_based_degree_sequence(rd_nx_degree_sequence, file_location)
      print_progress_bar()  # print("Write Graphs to files")
  
      nx.write_pajek(st_nx_graph, file_location + "random.net")
      nx.write_pajek(nd_nx_graph, file_location + "scale-free.net")
      nx.write_pajek(th_nx_graph,
                     file_location + "randomForMotifs.net")
      rd_nx_graph_nl_lst = export_to_pajek(rd_nx_graph, st_graph_obj.n)
  
      with open(file_location + 'combinedFixed.net', 'w') as f:
          for item in rd_nx_graph_nl_lst:
              f.write("%s\n" % item)
  
          print_progress_bar()  # print("Create Motifs")
      motifs = create_motifs(init_scale=init_scale, p_val=p_val, file_location=file_location)
      print_progress_bar()  # print("Calculate Similarity ")
      motifs_result = motifs_main_calculation(motifs, rd_nx_graph, th_nx_graph, file_location)
      print_progress_bar()  # print("Calculate Z-Score")
      z_score_result = calc_z_score(motifs_result, tmp_uid, file_location)
      max_z_score = 0
      max_z_score_key = None
      for tmp_k in z_score_result:
          if z_score_result[tmp_k] > max_z_score:
              max_z_score = z_score_result[tmp_k]
              max_z_score_key = tmp_k
  
      rd_nx_graph_nl_lst = export_to_pajek_by_z_score(rd_nx_graph, st_graph_obj.n,
                                                      motifs_result["relGraph"][max_z_score_key],
                                                      file_location)
      sf_good_separate_cnt = 0
      rnd_good_separate_cnt = 0
      sf_bad_separate_cnt = 0
      rnd_bad_separate_cnt = 0
      with open(file_location + 'combinedFixed.net', 'w') as f:
          for item in rd_nx_graph_nl_lst:
              if "ellipse" in item:
                  if "Black" in item:
                      sf_good_separate_cnt = sf_good_separate_cnt + 1
                  else:
                      sf_bad_separate_cnt = sf_bad_separate_cnt + 1
              elif "box" in item:
                  if "Black" in item:
                      rnd_bad_separate_cnt = rnd_bad_separate_cnt + 1
                  else:
                      rnd_good_separate_cnt = rnd_good_separate_cnt + 1
  
              f.write("%s\n" % item)
  
      y_data = [sf_good_separate_cnt / node_cnt,
                sf_bad_separate_cnt / node_cnt,
                rnd_good_separate_cnt / node_cnt,
                rnd_bad_separate_cnt / node_cnt]
  
      x_data = ["Correct S-F", "Incorrect S-F", "Correct Rand", "Incorrect Rand"]
      bar_obj = plt.bar(x_data, y_data)
      bar_obj[0].set_color('g')
      bar_obj[1].set_color('r')
      bar_obj[2].set_color('g')
      bar_obj[3].set_color('r')
      for xy_data in zip(x_data, y_data):
          plt.annotate('{:.0%}'.format(xy_data[1]), xy=xy_data, textcoords='data')
      plt.savefig(file_location + "Bar-" + str(tmp_uid) + ".png", dpi=300)
      plt.clf()
      plt.cla()
      # print("---------------------------- End Iteration ------------------------\n\n\n\n")
      return y_data
  
  
  if __name__ == "__main__":
      node_cnt_m = 504
      p_val_m = 0.01
      edge_cnt_m = 1000
      init_scale_m = 10
      args = []
      for arg in sys.argv[1:]:
          args.append(arg)
      if not args:
          print("Could not Find argument")
          exit(1)
      try:
          args[0] = int(args[0])
      except ValueError:
          print("Argument must be an integer ")
          print("Usage : main.py X (Where X is an integer)")
          exit(2)
  
      start = time.time()
  
      if not os.path.exists("./Output"):
          os.makedirs("./Output")
      results = dict()
      run_rng = range(args[0])
  
      glob_itrs = len(run_rng) * 7 + 1
      glob_req_time = str(datetime.timedelta(seconds=20 * (len(run_rng))))
      print("Estimated Time To Complete - " + glob_req_time)
      for i in run_rng:
          tmp = start_here(node_cnt_m, p_val_m, edge_cnt_m, init_scale_m, i + 1)
          results[i + 1] = tmp
  
      sf_good_separate_cnt_m = []
      sf_bad_separate_cnt_m = []
      rnd_good_separate_cnt_m = []
      rnd_bad_separate_cnt_m = []
  
      for k in results:
          sf_good_separate_cnt_m.append(results[k][0])
          sf_bad_separate_cnt_m.append(results[k][1])
          rnd_good_separate_cnt_m.append(results[k][2])
          rnd_bad_separate_cnt_m.append(results[k][3])
  
      y = [statistics.mean(sf_good_separate_cnt_m),
           statistics.mean(sf_bad_separate_cnt_m),
           statistics.mean(rnd_good_separate_cnt_m),
           statistics.mean(rnd_bad_separate_cnt_m)]
      x = ["Correct S-F", "Incorrect S-F", "Correct Rand", "Incorrect Rand"]
  
      barObj_m = plt.bar(x, y)
      barObj_m[0].set_color('g')
      barObj_m[1].set_color('r')
      barObj_m[2].set_color('g')
      barObj_m[3].set_color('r')
      for xy in zip(x, y):
          plt.annotate('{:.0%}'.format(xy[1]), xy=xy, textcoords='data')
      plt.savefig("./Output/Bar.png", dpi=300)
      print_progress_bar()
      end = time.time()
      print("---------------- executing time --------------")
      print(end - start)
      print("---------------- executing time --------------")
  
apis: matplotlib.pyplot.savefig matplotlib.pyplot.cla matplotlib.pyplot.clf matplotlib.pyplot.bar