def test_nonEmptySet(self):
        Cu_mock = [[13], [14], [15], [16, 17], [18, 19], [20, 21, 22],
                   [23, 24, 25], [1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12],
                   [26, 27, 28, 29, 30]]

        G = graphFromList(Cu_mock).to_undirected()
        G2, I, C_D = collapse_graph(G)
        G2, R_D = renameGraph(G2)
        drawNetwork(G2, [], 'test images/abcd.png')

        max_T = 5

        T_size = 5
        # greedyselect 1
        response1 = greedySelect(Cu_mock, max_T, T_size, rd.uniform(0, 0.99))
        bought = translate(response1, C_D, R_D)
        drawNetwork(G2, bought, 'test images/abcd2.png')

        Cu_mock += [[31, 32, 33, 34, 35], [36, 37, 38, 39, 40]]

        T_size = 15

        G = graphFromList(Cu_mock).to_undirected()
        G2, I, C_D = collapse_graph(G)
        G2, R_D = renameGraph(G2)
        drawNetwork(G2, [], 'test images/test2.png')

        # greedyselect 2
        response2 = greedySelect(Cu_mock, max_T, T_size, 1)
        bought2 = translate(response2, C_D, R_D)
        drawNetwork(G2, bought2, 'test images/test2.1.png')
Example #2
0
 def test_MetaTreeConstruct(self):
     G, t_max = randomGraph(200)
     G2, I, C_D = collapse_graph(G, t_max)
     G2, R_D = renameGraph(G2)
     inverse_R_D = {value: key for key, value in R_D.items()}
     drawNetwork(G, [], 'test2.png')
     drawNetwork(G2, [], 'test_collapse2.png')
     l_I = [inverse_R_D[item] for item in I]
     M, M_D = constructMetaTree(G2, l_I)
     drawNetwork(M, [], 'test_metaTree.png')
Example #3
0
    def test_custom(self):
        max_T, T_size, Cu = constructCu()
        At, Av = subSetSelect(len(Cu), T_size - 1, Cu, 5)

        print('T_size', T_size)
        print('Av total size: ', 1 + sum(list(map(lambda x: len(x), Av))))
        print('At total size: ', 1 + sum(list(map(lambda x: len(x), At))))

        G = graphFromList(Cu).to_undirected()
        G2, I, C_D = collapse_graph(G)
        G2, R_D = renameGraph(G2)
        drawNetwork(G2, [], 'test1.1.png')

        bought1 = translate(At, C_D, R_D)
        bought2 = translate(Av, C_D, R_D)
        drawNetwork(G2, bought1, 'test1.2.png')
        drawNetwork(G2, bought2, 'test1.3.png')
    def test_custom(self):
        max_T, T_size, Cu = constructCu()

        G = graphFromList(Cu).to_undirected()
        G2, I, C_D = collapse_graph(G)
        G2, R_D = renameGraph(G2)
        drawNetwork(G2, [], 'test images/test1.0.png')

        print(max_T)

        Loop = True
        index = 1

        while Loop:
            alpha = float(input('Introduce an alpha to test: '))
            response1 = greedySelect(Cu, max_T, T_size, alpha)
            bought = translate(response1, C_D, R_D)
            drawNetwork(G2, bought, 'test images/test1.' + str(index) + '.png')
            index += 1
            Loop = int(
                input(
                    'Introduce 1 if you want to try again, otherwise introduce 0: '
                ))
Example #5
0
 def test_collapse(self):
     G, t_max = randomGraph(50)
     G2, I, C_D = collapse_graph(G, t_max)
     G2, R_D = renameGraph(G2)
     drawNetwork(G, [], 'test.png')
     drawNetwork(G2, [], 'test_collapse.png')