





_a									=				[
    ["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 lowerCAmelCase__(__snake_case							)    ->				List[Any]:







	'''simple docstring'''







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





def lowerCAmelCase__(__snake_case	,__snake_case							)    ->				int:







	'''simple docstring'''







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





def lowerCAmelCase__(__snake_case							)    ->				Tuple:







	'''simple docstring'''







	lowerCamelCase__        =		get_distinct_edge(__snake_case							)
	lowerCamelCase__        =		{}

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





def lowerCAmelCase__(__snake_case							)    ->				Optional[Any]:







	'''simple docstring'''







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





def lowerCAmelCase__(__snake_case							)    ->				Dict:







	'''simple docstring'''







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





def lowerCAmelCase__(__snake_case							)    ->				Tuple:







	'''simple docstring'''







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





def lowerCAmelCase__()    ->				None:







	'''simple docstring'''







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





def lowerCAmelCase__(__snake_case	,__snake_case	,__snake_case	,__snake_case							)    ->				Dict:







	'''simple docstring'''







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





def lowerCAmelCase__(__snake_case	,__snake_case							)    ->				List[Any]:







	'''simple docstring'''







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





def lowerCAmelCase__(__snake_case	,__snake_case	,__snake_case	,__snake_case=None							)    ->				Optional[Any]:







	'''simple docstring'''







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





def lowerCAmelCase__(__snake_case	,__snake_case	,__snake_case							)    ->				str:







	'''simple docstring'''







	lowerCamelCase__        =		int(s / 100 * (len(__snake_case							) - 1)							)
	for i in cluster[k]:
		my_dfs(__snake_case	,tuple(cluster[k][i]							)	,(['''Header'''],)							)





def lowerCAmelCase__(__snake_case							)    ->				int:







	'''simple docstring'''







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





def lowerCAmelCase__(__snake_case							)    ->				Tuple:







	'''simple docstring'''







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


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










import unittest

import numpy as np

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
			import torch

if is_vision_available():
			from PIL import Image

			from transformers import ViltImageProcessor






class  __A   (   unittest.TestCase			):

			'''simple docstring'''







			def __init__(   self	,  __lowerCAmelCase	,  __lowerCAmelCase=7	,  __lowerCAmelCase=3	,  __lowerCAmelCase=1_8	,  __lowerCAmelCase=3_0	,  __lowerCAmelCase=4_0_0	,  __lowerCAmelCase=True	,  __lowerCAmelCase=None	,  __lowerCAmelCase=2	,  __lowerCAmelCase=True	,  __lowerCAmelCase=[0.5, 0.5, 0.5]	,  __lowerCAmelCase=[0.5, 0.5, 0.5]	,  ):



				'''simple docstring'''







				lowerCamelCase__        =		size if size is not None else {'''shortest_edge''': 3_0}
				lowerCamelCase__        =		parent
				lowerCamelCase__        =		batch_size
				lowerCamelCase__        =		num_channels
				lowerCamelCase__        =		image_size
				lowerCamelCase__        =		min_resolution
				lowerCamelCase__        =		max_resolution
				lowerCamelCase__        =		do_resize
				lowerCamelCase__        =		size
				lowerCamelCase__        =		size_divisor
				lowerCamelCase__        =		do_normalize
				lowerCamelCase__        =		image_mean
				lowerCamelCase__        =		image_std





			def 		__lowerCamelCase    (   self							):



				'''simple docstring'''







				return {
				    "image_mean": self.image_mean,
				    "image_std": self.image_std,
				    "do_normalize": self.do_normalize,
				    "do_resize": self.do_resize,
				    "size": self.size,
				    "size_divisor": self.size_divisor,
				}





			def 		__lowerCamelCase    (   self	,  __lowerCAmelCase	,  __lowerCAmelCase=False							):



				'''simple docstring'''







				if not batched:
					lowerCamelCase__        =		self.size['''shortest_edge''']
					lowerCamelCase__        =		image_inputs[0]
					if isinstance(__lowerCAmelCase	,  Image.Image							):
						lowerCamelCase__    ,     lowerCamelCase__        =		image.size
					else:
						lowerCamelCase__    ,     lowerCamelCase__        =		image.shape[1], image.shape[2]
					lowerCamelCase__        =		size / min(__lowerCAmelCase	,  __lowerCAmelCase							)
					if h < w:
						lowerCamelCase__    ,     lowerCamelCase__        =		size, scale * w
					else:
						lowerCamelCase__    ,     lowerCamelCase__        =		scale * h, size

					lowerCamelCase__        =		int((1_3_3_3 / 8_0_0) * size							)
					if max(__lowerCAmelCase	,  __lowerCAmelCase							) > max_size:
						lowerCamelCase__        =		max_size / max(__lowerCAmelCase	,  __lowerCAmelCase							)
						lowerCamelCase__        =		newh * scale
						lowerCamelCase__        =		neww * scale

					lowerCamelCase__    ,     lowerCamelCase__        =		int(newh + 0.5							), int(neww + 0.5							)
					lowerCamelCase__    ,     lowerCamelCase__        =		(
					    newh // self.size_divisor * self.size_divisor,
					    neww // self.size_divisor * self.size_divisor,
					)

				else:
					lowerCamelCase__        =		[]
					for image in image_inputs:
						lowerCamelCase__    ,     lowerCamelCase__        =		self.get_expected_values([image]							)
						expected_values.append((expected_height, expected_width)							)
					lowerCamelCase__        =		max(__lowerCAmelCase	,  key=lambda __lowerCAmelCase							: item[0]							)[0]
					lowerCamelCase__        =		max(__lowerCAmelCase	,  key=lambda __lowerCAmelCase							: item[1]							)[1]

				return expected_height, expected_width






@require_torch
@require_vision
class  __A   (   lowerCAmelCase      ,    unittest.TestCase			):

			'''simple docstring'''







			lowerCAmelCase_												=						ViltImageProcessor if is_vision_available() else None





			def 		__lowerCamelCase    (   self							):



				'''simple docstring'''







				lowerCamelCase__        =		ViltImageProcessingTester(self							)





			@property
			def 		__lowerCamelCase    (   self							):



				'''simple docstring'''







				return self.image_processor_tester.prepare_image_processor_dict()





			def 		__lowerCamelCase    (   self							):



				'''simple docstring'''







				lowerCamelCase__        =		self.image_processing_class(**self.image_processor_dict							)
				self.assertTrue(hasattr(__lowerCAmelCase	,  '''image_mean'''							)							)
				self.assertTrue(hasattr(__lowerCAmelCase	,  '''image_std'''							)							)
				self.assertTrue(hasattr(__lowerCAmelCase	,  '''do_normalize'''							)							)
				self.assertTrue(hasattr(__lowerCAmelCase	,  '''do_resize'''							)							)
				self.assertTrue(hasattr(__lowerCAmelCase	,  '''size'''							)							)
				self.assertTrue(hasattr(__lowerCAmelCase	,  '''size_divisor'''							)							)





			def 		__lowerCamelCase    (   self							):



				'''simple docstring'''







				lowerCamelCase__        =		self.image_processing_class.from_dict(self.image_processor_dict							)
				self.assertEqual(image_processor.size	,  {'''shortest_edge''': 3_0}							)

				lowerCamelCase__        =		self.image_processing_class.from_dict(self.image_processor_dict	,  size=4_2							)
				self.assertEqual(image_processor.size	,  {'''shortest_edge''': 4_2}							)





			def 		__lowerCamelCase    (   self							):



				'''simple docstring'''







				pass





			def 		__lowerCamelCase    (   self							):



				'''simple docstring'''







				lowerCamelCase__        =		self.image_processing_class(**self.image_processor_dict							)
				# create random PIL images
				lowerCamelCase__        =		prepare_image_inputs(self.image_processor_tester	,  equal_resolution=__lowerCAmelCase							)
				for image in image_inputs:
					self.assertIsInstance(__lowerCAmelCase	,  Image.Image							)

				# Test not batched input
				lowerCamelCase__        =		image_processing(image_inputs[0]	,  return_tensors='''pt'''							).pixel_values

				lowerCamelCase__    ,     lowerCamelCase__        =		self.image_processor_tester.get_expected_values(__lowerCAmelCase							)
				self.assertEqual(
				    encoded_images.shape	,  (1, self.image_processor_tester.num_channels, expected_height, expected_width)	,  )

				# Test batched
				lowerCamelCase__        =		image_processing(__lowerCAmelCase	,  return_tensors='''pt'''							).pixel_values

				lowerCamelCase__    ,     lowerCamelCase__        =		self.image_processor_tester.get_expected_values(__lowerCAmelCase	,  batched=__lowerCAmelCase							)
				self.assertEqual(
				    encoded_images.shape	,  (
				        self.image_processor_tester.batch_size,
				        self.image_processor_tester.num_channels,
				        expected_height,
				        expected_width,
				    )	,  )





			def 		__lowerCamelCase    (   self							):



				'''simple docstring'''







				lowerCamelCase__        =		self.image_processing_class(**self.image_processor_dict							)
				# create random numpy tensors
				lowerCamelCase__        =		prepare_image_inputs(self.image_processor_tester	,  equal_resolution=__lowerCAmelCase	,  numpify=__lowerCAmelCase							)
				for image in image_inputs:
					self.assertIsInstance(__lowerCAmelCase	,  np.ndarray							)

				# Test not batched input
				lowerCamelCase__        =		image_processing(image_inputs[0]	,  return_tensors='''pt'''							).pixel_values

				lowerCamelCase__    ,     lowerCamelCase__        =		self.image_processor_tester.get_expected_values(__lowerCAmelCase							)
				self.assertEqual(
				    encoded_images.shape	,  (1, self.image_processor_tester.num_channels, expected_height, expected_width)	,  )

				# Test batched
				lowerCamelCase__        =		image_processing(__lowerCAmelCase	,  return_tensors='''pt'''							).pixel_values

				lowerCamelCase__    ,     lowerCamelCase__        =		self.image_processor_tester.get_expected_values(__lowerCAmelCase	,  batched=__lowerCAmelCase							)
				self.assertEqual(
				    encoded_images.shape	,  (
				        self.image_processor_tester.batch_size,
				        self.image_processor_tester.num_channels,
				        expected_height,
				        expected_width,
				    )	,  )





			def 		__lowerCamelCase    (   self							):



				'''simple docstring'''







				lowerCamelCase__        =		self.image_processing_class(**self.image_processor_dict							)
				# create random PyTorch tensors
				lowerCamelCase__        =		prepare_image_inputs(self.image_processor_tester	,  equal_resolution=__lowerCAmelCase	,  torchify=__lowerCAmelCase							)
				for image in image_inputs:
					self.assertIsInstance(__lowerCAmelCase	,  torch.Tensor							)

				# Test not batched input
				lowerCamelCase__        =		image_processing(image_inputs[0]	,  return_tensors='''pt'''							).pixel_values

				lowerCamelCase__    ,     lowerCamelCase__        =		self.image_processor_tester.get_expected_values(__lowerCAmelCase							)
				self.assertEqual(
				    encoded_images.shape	,  (1, self.image_processor_tester.num_channels, expected_height, expected_width)	,  )

				# Test batched
				lowerCamelCase__        =		image_processing(__lowerCAmelCase	,  return_tensors='''pt'''							).pixel_values

				lowerCamelCase__    ,     lowerCamelCase__        =		self.image_processor_tester.get_expected_values(__lowerCAmelCase	,  batched=__lowerCAmelCase							)
				self.assertEqual(
				    encoded_images.shape	,  (
				        self.image_processor_tester.batch_size,
				        self.image_processor_tester.num_channels,
				        expected_height,
				        expected_width,
				    )	,  )



