





UpperCAmelCase_											=  [
    ["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     A__					(						SCREAMING_SNAKE_CASE_      :			Any	)     ->     Optional[Any]:






   """simple docstring"""







   _UpperCAmelCase											=      set()
   for row in edge_array:
      for item in row:
         distinct_edge.add(item[0]	)
   return list(SCREAMING_SNAKE_CASE_	)
def     A__					(						SCREAMING_SNAKE_CASE_      :			Optional[Any]							,  SCREAMING_SNAKE_CASE_      :			Any	)     ->     List[Any]:






   """simple docstring"""







   _UpperCAmelCase											=      ['''0'''] * len(SCREAMING_SNAKE_CASE_	)
   for i, row in enumerate(SCREAMING_SNAKE_CASE_	):
      for item in row:
         if distinct_edge in item[0]:
            _UpperCAmelCase											=      '''1'''
            break
   return "".join(SCREAMING_SNAKE_CASE_	)
def     A__					(						SCREAMING_SNAKE_CASE_      :			List[Any]	)     ->     Optional[Any]:






   """simple docstring"""







   _UpperCAmelCase											=      get_distinct_edge(SCREAMING_SNAKE_CASE_	)
   _UpperCAmelCase											=      {}

   for item in distinct_edge:
      _UpperCAmelCase											=      get_bitcode(SCREAMING_SNAKE_CASE_							,  SCREAMING_SNAKE_CASE_	)
      # 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 SCREAMING_SNAKE_CASE_	: v[1][0]							,  reverse=SCREAMING_SNAKE_CASE_	)
   ]
   return sorted_frequency_table
def     A__					(						SCREAMING_SNAKE_CASE_      :			Any	)     ->     str:






   """simple docstring"""







   _UpperCAmelCase											=      {}
   for _, item in enumerate(SCREAMING_SNAKE_CASE_	):
      nodes.setdefault(item[2]							,  []	).append(item[0]	)
   return nodes
def     A__					(						SCREAMING_SNAKE_CASE_      :			List[str]	)     ->     Optional[int]:






   """simple docstring"""







   _UpperCAmelCase											=      {}
   for key, value in nodes.items():
      _UpperCAmelCase											=      value
   return cluster
def     A__					(						SCREAMING_SNAKE_CASE_      :			str	)     ->     Dict:






   """simple docstring"""







   return [i * 1_00 / len(SCREAMING_SNAKE_CASE_	) for i in cluster]
def     A__					(						)     ->     None:






   """simple docstring"""







   print('''\nNodes\n'''	)
   for key, value in nodes.items():
      print(SCREAMING_SNAKE_CASE_							,  SCREAMING_SNAKE_CASE_	)
   print('''\nSupport\n'''	)
   print(SCREAMING_SNAKE_CASE_	)
   print('''\n Cluster \n'''	)
   for key, value in sorted(cluster.items()							,  reverse=SCREAMING_SNAKE_CASE_	):
      print(SCREAMING_SNAKE_CASE_							,  SCREAMING_SNAKE_CASE_	)
   print('''\n Graph\n'''	)
   for key, value in graph.items():
      print(SCREAMING_SNAKE_CASE_							,  SCREAMING_SNAKE_CASE_	)
   print('''\n Edge List of Frequent subgraphs \n'''	)
   for edge_list in freq_subgraph_edge_list:
      print(SCREAMING_SNAKE_CASE_	)
def     A__					(						SCREAMING_SNAKE_CASE_      :			Optional[Any]							,  SCREAMING_SNAKE_CASE_      :			Optional[int]							,  SCREAMING_SNAKE_CASE_      :			Dict							,  SCREAMING_SNAKE_CASE_      :			int	)     ->     List[Any]:






   """simple docstring"""







   for i in cluster[ca]:
      _UpperCAmelCase											=      0
      _UpperCAmelCase											=      ca + 1
      while ca < max(cluster.keys()	):
         for j in cluster[ca]:
            if int(SCREAMING_SNAKE_CASE_							,  2	) & int(SCREAMING_SNAKE_CASE_							,  2	) == int(SCREAMING_SNAKE_CASE_							,  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     A__					(						SCREAMING_SNAKE_CASE_      :			List[Any]							,  SCREAMING_SNAKE_CASE_      :			List[str]	)     ->     List[Any]:






   """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(SCREAMING_SNAKE_CASE_	) - 1:
      create_edge(SCREAMING_SNAKE_CASE_							,  SCREAMING_SNAKE_CASE_							,  SCREAMING_SNAKE_CASE_							,  SCREAMING_SNAKE_CASE_	)
      _UpperCAmelCase											=      i + 1
   return graph
def     A__					(						SCREAMING_SNAKE_CASE_      :			str							,  SCREAMING_SNAKE_CASE_      :			int							,  SCREAMING_SNAKE_CASE_      :			int							,  SCREAMING_SNAKE_CASE_      :			Optional[int]=None	)     ->     Union[str, Any]:






   """simple docstring"""







   _UpperCAmelCase											=      (path or []) + [start]
   if start == end:
      paths.append(SCREAMING_SNAKE_CASE_	)
   for node in graph[start]:
      if tuple(SCREAMING_SNAKE_CASE_	) not in path:
         my_dfs(SCREAMING_SNAKE_CASE_							,  tuple(SCREAMING_SNAKE_CASE_	)							,  SCREAMING_SNAKE_CASE_							,  SCREAMING_SNAKE_CASE_	)
def     A__					(						SCREAMING_SNAKE_CASE_      :			str							,  SCREAMING_SNAKE_CASE_      :			Dict							,  SCREAMING_SNAKE_CASE_      :			Dict	)     ->     str:






   """simple docstring"""







   _UpperCAmelCase											=      int(s / 1_00 * (len(SCREAMING_SNAKE_CASE_	) - 1)	)
   for i in cluster[k]:
      my_dfs(SCREAMING_SNAKE_CASE_							,  tuple(cluster[k][i]	)							,  (['''Header'''],)	)
def     A__					(						SCREAMING_SNAKE_CASE_      :			str	)     ->     Union[str, Any]:






   """simple docstring"""







   _UpperCAmelCase											=      []
   for edges in paths:
      _UpperCAmelCase											=      []
      for j in range(len(SCREAMING_SNAKE_CASE_	) - 1	):
         _UpperCAmelCase											=      list(edges[j]	)
         for e in temp:
            _UpperCAmelCase											=      (e[0], e[1])
            el.append(SCREAMING_SNAKE_CASE_	)
      freq_sub_el.append(SCREAMING_SNAKE_CASE_	)
   return freq_sub_el
def     A__					(						SCREAMING_SNAKE_CASE_      :			Any	)     ->     Any:






   """simple docstring"""







   for i in range(len(SCREAMING_SNAKE_CASE_	)	):
      for j in range(len(edge_array[i]	)	):
         _UpperCAmelCase											=      edge_array[i][j].split('''-'''	)
         _UpperCAmelCase											=      t


if __name__ == "__main__":
   preprocess(edge_array)
   UpperCAmelCase_											=  get_frequency_table(edge_array)
   UpperCAmelCase_											=  get_nodes(frequency_table)
   UpperCAmelCase_											=  get_cluster(nodes)
   UpperCAmelCase_											=  get_support(cluster)
   UpperCAmelCase_											=  construct_graph(cluster, nodes)
   find_freq_subgraph_given_support(60, cluster, graph)
   UpperCAmelCase_											=  []
   UpperCAmelCase_											=  freq_subgraphs_edge_list(paths)
   print_all()






def     A__					(						SCREAMING_SNAKE_CASE_      :			list	)     ->     bool:






   """simple docstring"""







   if not isinstance(SCREAMING_SNAKE_CASE_							,  SCREAMING_SNAKE_CASE_	):
      raise ValueError('''Input series is not valid, valid series - [1, 2/3, 2]'''	)
   if len(SCREAMING_SNAKE_CASE_	) == 0:
      raise ValueError('''Input list must be a non empty list'''	)
   if len(SCREAMING_SNAKE_CASE_	) == 1 and series[0] != 0:
      return True
   _UpperCAmelCase											=      []
   _UpperCAmelCase											=      len(SCREAMING_SNAKE_CASE_	)
   for i in range(0							,  SCREAMING_SNAKE_CASE_	):
      if series[i] == 0:
         raise ValueError('''Input series cannot have 0 as an element'''	)
      rec_series.append(1 / series[i]	)
   _UpperCAmelCase											=      rec_series[1] - rec_series[0]
   for index in range(2							,  SCREAMING_SNAKE_CASE_	):
      if rec_series[index] - rec_series[index - 1] != common_diff:
         return False
   return True
def     A__					(						SCREAMING_SNAKE_CASE_      :			list	)     ->     float:






   """simple docstring"""







   if not isinstance(SCREAMING_SNAKE_CASE_							,  SCREAMING_SNAKE_CASE_	):
      raise ValueError('''Input series is not valid, valid series - [2, 4, 6]'''	)
   if len(SCREAMING_SNAKE_CASE_	) == 0:
      raise ValueError('''Input list must be a non empty list'''	)
   _UpperCAmelCase											=      0
   for val in series:
      answer += 1 / val
   return len(SCREAMING_SNAKE_CASE_	) / answer


if __name__ == "__main__":
   import doctest

   doctest.testmod()