Пример #1
0
    def test_checkIfUndecidedExists(self):
        adjacencyMatrix = getUnitDiskGraph(50)

        network = Network(adjacencyMatrix)

        alg = SlowMIS()
        alg.network = network

        alg.initiate()

        result = alg.checkIfUndecidedExists()

        self.failUnless(result == True)

        # zmiana stanow wezlow

        for node in network.ndList:
            node.memory["state"] = "in_MIS"

        result = alg.checkIfUndecidedExists()

        self.failUnless(result == False)

        network.ndList[38].memory["state"] = "undecided"

        result = alg.checkIfUndecidedExists()

        self.failUnless(result == True)
Пример #2
0
    def test_execute(self):
        adjacencyMatrix = getUnitDiskGraph(200)

        network = Network(adjacencyMatrix)

        alg = SlowMIS()
        alg.network = network

        alg.execute()

        # sprawdzenie wlasnosci wyliczonego MIS

        for node in network.ndList:

            # stany wszystkich sasiadow
            states = [network.ndList[neigh].memory["state"] for neigh in node.neighbors]

            if node.memory["state"] == "not_in_MIS":
                # fail jesli wszystkie wezly tez nie sa w MIS
                self.failIf(all([state == "not_in_MIS" for state in states]))

            elif node.memory["state"] == "in_MIS":
                self.failIf(any([state == "in_MIS" for state in states]))
            else:
                self.fail("nieprawidlowy stan")