Ejemplo n.º 1
0
    def test_decrease_key(self):
        nodes = []
        maxNode = None

        H = FibHeap()
        random.seed()

        for d in range(10000):
            n = FibNode(random.randint(1, 100000))
            if maxNode == None or n.get_key() > maxNode.get_key():
                maxNode = n
            nodes.append(n)
            H.insert_node(n)

        H.decrease_key(maxNode, H.get_min().get_key())

        self.assertEqual(maxNode.get_key(), H.get_min().get_key())
Ejemplo n.º 2
0
	def test_decrease_key(self):
		nodes = []
		maxNode = None
	
		H = FibHeap()
		random.seed()
		
		for d in range(10000):
			n = FibNode(random.randint(1, 100000))
			if maxNode == None or n.get_key() > maxNode.get_key():
				maxNode = n
			nodes.append(n)
			H.insert_node(n)
		
		H.decrease_key(maxNode, H.get_min().get_key())	
		
		self.assertEqual(maxNode.get_key(), H.get_min().get_key())
Ejemplo n.º 3
0
    def test_insert_data(self):
        nodes = []
        minNode = None

        H = FibHeap()
        random.seed()

        for d in range(10000):
            n = FibNode(random.randint(1, 100000))
            if minNode == None or n.get_key() < minNode.get_key():
                minNode = n
            nodes.append(n)
            H.insert_node(n)

        self.assertEqual(H.get_min(), minNode)
Ejemplo n.º 4
0
	def test_insert_data(self):
		nodes = []
		minNode=None
	
		H = FibHeap()
		random.seed()
		
		for d in range(10000):
			n = FibNode(random.randint(1, 100000))
			if minNode == None or n.get_key() < minNode.get_key():
				minNode = n
			nodes.append(n)
			H.insert_node(n)
		
		self.assertEqual(H.get_min(), minNode)