# Path: common/data_structures.py
# class Node(object):
# 
#     def __init__(self):
#         self.children = list()
# 
#     def add_child(self, child):
#         self.children.append(child)
# 
#     def get_child(self, index):
#         return self.children[index]
# 
#     def __iter__(self):
#         return iter(self.children)
# 
#     def __eq__(self, other):
#         return self.value == other.value
# 
# Path: search/uninformed_search.py
# def dls(node, target, limit, comparator=lambda x, y: x == y):
#     queue = [(node, 0)]
#     visited_nodes = []
#     max_level = 0
# 
#     while len(queue) != 0:
#         current_node, current_node_level = queue.pop()
#         max_level = max(max_level, current_node_level)
# 
#         if current_node_level <= limit and current_node not in visited_nodes:
#                 if comparator(current_node.value, target):
#                     return current_node, current_node_level
# 
#                 if current_node_level < limit:
#                     queue.extend([(child, current_node_level + 1) for child in current_node])
# 
#                 visited_nodes.append(current_node)
# 
#     return None, max_level


from unittest.case import TestCase
from common.data_structures import Node
from search.uninformed_search import dls

    @staticmethod
    def prepare_graph1():
        node = Node()
        node.value = '1'

        node2 = Node()
        node2.value = '2'
        node.add_child(node2)
        node21 = Node()
        node21.value = '3'
        node.add_child(node21)

        node3 = Node()
        node3.value = '4'
        node2.add_child(node3)

        node4 = Node()
        node4.value = '5'
        node3.add_child(node4)
        node21.add_child(node4)

        node5 = Node()
        node5.value = '6'
        node3.add_child(node5)

        return node

    def test_tree1(self):
        node = DepthLimitedSearchTest.prepare_tree1()

# Path: common/data_structures.py
# class Node(object):
# 
#     def __init__(self):
#         self.children = list()
# 
#     def add_child(self, child):
#         self.children.append(child)
# 
#     def get_child(self, index):
#         return self.children[index]
# 
#     def __iter__(self):
#         return iter(self.children)
# 
#     def __eq__(self, other):
#         return self.value == other.value
# 
# Path: search/uninformed_search.py
# def dls(node, target, limit, comparator=lambda x, y: x == y):
#     queue = [(node, 0)]
#     visited_nodes = []
#     max_level = 0
# 
#     while len(queue) != 0:
#         current_node, current_node_level = queue.pop()
#         max_level = max(max_level, current_node_level)
# 
#         if current_node_level <= limit and current_node not in visited_nodes:
#                 if comparator(current_node.value, target):
#                     return current_node, current_node_level
# 
#                 if current_node_level < limit:
#                     queue.extend([(child, current_node_level + 1) for child in current_node])
# 
#                 visited_nodes.append(current_node)
# 
#     return None, max_level


# Path: tests/search/dls_test.py
from unittest.case import TestCase
from common.data_structures import Node
from search.uninformed_search import dls


    @staticmethod
    def prepare_graph1():
        node = Node()
        node.value = '1'

        node2 = Node()
        node2.value = '2'
        node.add_child(node2)
        node21 = Node()
        node21.value = '3'
        node.add_child(node21)

        node3 = Node()
        node3.value = '4'
        node2.add_child(node3)

        node4 = Node()
        node4.value = '5'
        node3.add_child(node4)
        node21.add_child(node4)

        node5 = Node()
        node5.value = '6'
        node3.add_child(node5)

        return node

    def test_tree1(self):
        node = DepthLimitedSearchTest.prepare_tree1()

        result = dls(node, '5', 10)