def test_execute(self):
     n = 50
     adjacencyMatrix = getPlanarGraph(n)
     
     network = Network(adjacencyMatrix)
     
     # sprawdzenie metody
     alg = PlanarMIS(network)
     alg.execute()
     
     # sprawdzanie:
     # standardowo jak w MIS
     for node in network.ndList:
         if node.memory['is_in_final_MIS'] == True:
             for neigh in node.neighbors:
                 self.failIf(network.ndList[neigh].memory['is_in_final_MIS'] == True)
                 
         # jesli wezel jest zdominowany, to fail jesli ma w swoim otoczeniu same zdominowane wezly
         elif node.memory['is_in_final_MIS'] == False:
             neigh_states = [network.ndList[neigh].memory['is_in_final_MIS'] for neigh in node.neighbors]
             
             self.failIf(all([state == False for state in neigh_states]))
         # jesli wezel nie jest ani dominatorem ani zdominownay, to fail
         else:
             self.fail("nieprawidlowy stan wezla")
def compute():

    MIN = 50
    MAX = 5000
    step = 500

    repetitions = 100

    adjMatrix = []
    alg = None
    network = None

    tempCommSum = 0
    commTimes = []

    tempAlgSum = 0
    algTimes = []

    for n in range(MIN, MAX, step):
        tempCommSum = 0
        tempAlgSum = 0

        for k in range(repetitions):
            adjMatrix = getPlanarGraph(n)
            network = Network(adjMatrix)

            alg = PlanarMIS(network)

            alg.execute()

            print k
            tempCommSum += network.algCommRoundCounter
            tempAlgSum += alg.roundCounter

        print n, "time: ", datetime.now()

        commTimes.append(tempCommSum / float(repetitions))
        algTimes.append(tempAlgSum / float(repetitions))

    # print times

    fileName = "/home/julka/100_reps/modified_log_star_MIS_planar_graph_comm.txt"
    save(commTimes, fileName)

    fileName = "/home/julka/100_reps/modified_log_star_MIS_planar_graph_alg.txt"
    save(algTimes, fileName)