


'''simple docstring'''







import os
import sys
import time

from . import transposition_cipher as trans_cipher







def _UpperCamelCase	(					)							->		None:


      '''simple docstring'''



      UpperCamelCase__  =    "Prehistoric Men.txt"
      UpperCamelCase__  =    "Output.txt"
      UpperCamelCase__  =    int(input("Enter key: "   )   )
      UpperCamelCase__  =    input("Encrypt/Decrypt [e/d]: "   )

      if not os.path.exists(__A   ):
            print(F'''File {input_file} does not exist. Quitting...'''   )
            sys.exit()
      if os.path.exists(__A   ):
            print(F'''Overwrite {output_file}? [y/n]'''   )
            UpperCamelCase__  =    input("> "   )
            if not response.lower().startswith("y"   ):
                  sys.exit()

      UpperCamelCase__  =    time.time()
      if mode.lower().startswith("e"   ):
            with open(__A   ) as f:
                  UpperCamelCase__  =    f.read()
            UpperCamelCase__  =    trans_cipher.encrypt_message(__A				,      __A   )
      elif mode.lower().startswith("d"   ):
            with open(__A   ) as f:
                  UpperCamelCase__  =    f.read()
            UpperCamelCase__  =    trans_cipher.decrypt_message(__A				,      __A   )

      with open(__A				,      "w"   ) as output_obj:
            output_obj.write(__A   )

      UpperCamelCase__  =    round(time.time() - start_time				,      2   )
      print(("Done (", total_time, "seconds )")   )


if __name__ == "__main__":
  main()





'''simple docstring'''







a__  : str				=	[
    ['ab-e1', 'ac-e3', 'ad-e5', 'bc-e4', 'bd-e2', 'be-e6', 'bh-e12', 'cd-e2', 'ce-e4',
     'de-e1', 'df-e8', 'dg-e5', 'dh-e10', 'ef-e3', 'eg-e2', 'fg-e6', 'gh-e6', 'hi-e3'],
    ['ab-e1', 'ac-e3', 'ad-e5', 'bc-e4', 'bd-e2', 'be-e6', 'cd-e2', 'de-e1', 'df-e8',
     'ef-e3', 'eg-e2', 'fg-e6'],
    ['ab-e1', 'ac-e3', 'bc-e4', 'bd-e2', 'de-e1', 'df-e8', 'dg-e5', 'ef-e3', 'eg-e2',
     'eh-e12', 'fg-e6', 'fh-e10', 'gh-e6'],
    ['ab-e1', 'ac-e3', 'bc-e4', 'bd-e2', 'bh-e12', 'cd-e2', 'df-e8', 'dh-e10'],
    ['ab-e1', 'ac-e3', 'ad-e5', 'bc-e4', 'bd-e2', 'cd-e2', 'ce-e4', 'de-e1', 'df-e8',
     'dg-e5', 'ef-e3', 'eg-e2', 'fg-e6']
]







def _UpperCamelCase	(					__A   )							->		Tuple:


      '''simple docstring'''



      UpperCamelCase__  =    set()
      for row in edge_array:
            for item in row:
                  distinct_edge.add(item[0]   )
      return list(__A   )







def _UpperCamelCase	(					__A				,      __A   )							->		int:


      '''simple docstring'''



      UpperCamelCase__  =    ["0"] * len(__A   )
      for i, row in enumerate(__A   ):
            for item in row:
                  if distinct_edge in item[0]:
                        UpperCamelCase__  =    "1"
                        break
      return "".join(__A   )







def _UpperCamelCase	(					__A   )							->		Union[str, Any]:


      '''simple docstring'''



      UpperCamelCase__  =    get_distinct_edge(__A   )
      UpperCamelCase__  =    {}

      for item in distinct_edge:
            UpperCamelCase__  =    get_bitcode(__A				,      __A   )
            # print('bit',bit)
            # bt=''.join(bit)
            UpperCamelCase__  =    bit.count("1"   )
            UpperCamelCase__  =    [s, bit]
      # Store [Distinct edge, WT(Bitcode), Bitcode] in descending order
      UpperCamelCase__  =    [
          [k, v[0], v[1]]
          for k, v in sorted(frequency_table.items()				,      key=lambda __A   : v[1][0]				,      reverse=__A   )
      ]
      return sorted_frequency_table







def _UpperCamelCase	(					__A   )							->		Union[str, Any]:


      '''simple docstring'''



      UpperCamelCase__  =    {}
      for _, item in enumerate(__A   ):
            nodes.setdefault(item[2]				,      []   ).append(item[0]   )
      return nodes







def _UpperCamelCase	(					__A   )							->		Tuple:


      '''simple docstring'''



      UpperCamelCase__  =    {}
      for key, value in nodes.items():
            UpperCamelCase__  =    value
      return cluster







def _UpperCamelCase	(					__A   )							->		str:


      '''simple docstring'''



      return [i * 100 / len(__A   ) for i in cluster]







def _UpperCamelCase	(					)							->		None:


      '''simple docstring'''



      print("\nNodes\n"   )
      for key, value in nodes.items():
            print(__A				,      __A   )
      print("\nSupport\n"   )
      print(__A   )
      print("\n Cluster \n"   )
      for key, value in sorted(cluster.items()				,      reverse=__A   ):
            print(__A				,      __A   )
      print("\n Graph\n"   )
      for key, value in graph.items():
            print(__A				,      __A   )
      print("\n Edge List of Frequent subgraphs \n"   )
      for edge_list in freq_subgraph_edge_list:
            print(__A   )







def _UpperCamelCase	(					__A				,      __A				,      __A				,      __A   )							->		Optional[int]:


      '''simple docstring'''



      for i in cluster[ca]:
            UpperCamelCase__  =    0
            UpperCamelCase__  =    ca + 1
            while ca < max(cluster.keys()   ):
                  for j in cluster[ca]:
                        if int(__A				,      2   ) & int(__A				,      2   ) == int(__A				,      2   ):
                              if tuple(nodes[i]   ) in graph:
                                    graph[tuple(nodes[i]   )].append(nodes[j]   )
                              else:
                                    UpperCamelCase__  =    [nodes[j]]
                              count += 1
                  if count == 0:
                        UpperCamelCase__  =    ca + 1
                  else:
                        break







def _UpperCamelCase	(					__A				,      __A   )							->		List[str]:


      '''simple docstring'''



      UpperCamelCase__  =    cluster[max(cluster.keys()   )]
      UpperCamelCase__  =    "Header"
      UpperCamelCase__  =    {}
      for i in x:
            if (["Header"],) in graph:
                  graph[(["Header"],)].append(x[i]   )
            else:
                  UpperCamelCase__  =    [x[i]]
      for i in x:
            UpperCamelCase__  =    [["Header"]]
      UpperCamelCase__  =    1
      while i < max(__A   ) - 1:
            create_edge(__A				,      __A				,      __A				,      __A   )
            UpperCamelCase__  =    i + 1
      return graph







def _UpperCamelCase	(					__A				,      __A				,      __A				,      __A=None   )							->		str:


      '''simple docstring'''



      UpperCamelCase__  =    (path or []) + [start]
      if start == end:
            paths.append(__A   )
      for node in graph[start]:
            if tuple(__A   ) not in path:
                  my_dfs(__A				,      tuple(__A   )				,      __A				,      __A   )







def _UpperCamelCase	(					__A				,      __A				,      __A   )							->		Union[str, Any]:


      '''simple docstring'''



      UpperCamelCase__  =    int(s / 100 * (len(__A   ) - 1)   )
      for i in cluster[k]:
            my_dfs(__A				,      tuple(cluster[k][i]   )				,      (["Header"],)   )







def _UpperCamelCase	(					__A   )							->		Optional[Any]:


      '''simple docstring'''



      UpperCamelCase__  =    []
      for edges in paths:
            UpperCamelCase__  =    []
            for j in range(len(__A   ) - 1   ):
                  UpperCamelCase__  =    list(edges[j]   )
                  for e in temp:
                        UpperCamelCase__  =    (e[0], e[1])
                        el.append(__A   )
            freq_sub_el.append(__A   )
      return freq_sub_el







def _UpperCamelCase	(					__A   )							->		Optional[int]:


      '''simple docstring'''



      for i in range(len(__A   )   ):
            for j in range(len(edge_array[i]   )   ):
                  UpperCamelCase__  =    edge_array[i][j].split("-"   )
                  UpperCamelCase__  =    t


if __name__ == "__main__":
  preprocess(edge_array)
  a__  : List[Any]				=	get_frequency_table(edge_array)
  a__  : Optional[int]				=	get_nodes(frequency_table)
  a__  : Any				=	get_cluster(nodes)
  a__  : Tuple				=	get_support(cluster)
  a__  : str				=	construct_graph(cluster, nodes)
  find_freq_subgraph_given_support(6_0, cluster, graph)
  a__  : list				=	[]
  a__  : str				=	freq_subgraphs_edge_list(paths)
  print_all()





