def rapport_approxim(nmax, p):
    x = []
    y1 = []
    y2 = []
    N = nmax * (np.arange(10) + 1) / 10
    if (nmax > 1):
        for i in (N):
            print(i)
            i = int(i) + 1
            x.append(i)
            rcumul1 = 0
            rcumul2 = 0
            for j in range(10):
                g = imp.gen_graphe(i, p)
                while (imp.is_empty(g)):
                    g = imp.gen_graphe(i, p)
                t, C, nb_n = imp.branch_born_ameliore1(g)
                c1 = len(C)
                c2 = len(imp.couplage(g))
                c3 = len(imp.glouton(g))
                rcumul1 += c2 / c1
                rcumul2 += c3 / c1
            y1.append(rcumul1 / 10)
            y2.append(rcumul2 / 10)
        return x, y1, y2
    else:
        print('nmax doit etre supérieur à 1')
        return None
def test_couplage(nmax, p):
    x = []
    y = []
    xl = []
    yl = []
    N = nmax * (np.arange(10) + 1) / 10
    if (nmax > 1):
        for i in (N):
            i = int(i) + 1
            x.append(i)
            xl.append(math.log(i))
            tcumul = 0
            for j in range(10):
                g = imp.gen_graphe(i, p)
                while (imp.is_empty(g)):
                    g = imp.gen_graphe(i, p)
                start_time = time.time()
                C = imp.couplage(g)
                end_time = time.time()
                t = (end_time - start_time)
                tcumul += t
            y.append(tcumul / 10)
            yl.append(math.log(tcumul / 10))
        return x, y, xl, yl
    else:
        print('nmax doit etre supérieur à 1')
        return None
def compare_couplage_glouton(nmax, p):
    x = []
    y1 = []
    y2 = []
    N = nmax * (np.arange(10) + 1) / 10
    if (nmax > 1):
        for i in (N):
            i = int(i) + 1
            x.append(i)
            cumul1 = 0
            cumul2 = 0
            for j in range(20):
                g = imp.gen_graphe(i, p)
                while (imp.is_empty(g)):
                    g = imp.gen_graphe(i, p)
                c2 = len(imp.glouton(g))
                c1 = len(imp.couplage(g))
                if (c1 < c2):
                    cumul1 += 1
                else:
                    if (c2 < c1):
                        cumul2 += 1
                    else:
                        cumul2 += 1
                        cumul1 += 1
            y1.append(cumul1)
            y2.append(cumul2)
        return x, y1, y2
    else:
        print('nmax doit etre supérieur à 1')
        return None
def test_couplage_p(n):
    x = []
    y = []
    xl = []
    yl = []
    if (n > 1):
        for i in np.arange(0.1, 1, 0.01):
            x.append(i)
            xl.append(math.log(i))
            g = imp.gen_graphe2(n, i)
            start_time = time.time()
            c = imp.couplage(g)
            end_time = time.time()
            t = (end_time - start_time)
            y.append(t)
            yl.append(math.log(t))
        return x, y, xl, yl
    else:
        print('n doit etre supérieur à 1')
        return None
def rapport_approxim_p(n):
    x = []
    y1 = []
    y2 = []
    if (n > 1):
        for i in np.arange(0.1, 1, 0.01):
            print(i)
            i = int(i) + 1
            x.append(i)
            g = imp.gen_graphe2(n, i)
            t, C, nb_n = imp.branch_born_ameliore1(g)
            c1 = len(C)
            c2 = len(imp.couplage(g))
            c3 = len(imp.glouton(g))
            y1.append(c2 / c1)
            y2.append(c3 / c1)
        return x, y1, y2
    else:
        print('n doit etre supérieur à 1')
        return None
def ecart_couplage_glouton(nmax, p):
    x = []
    y = []
    N = nmax * (np.arange(10) + 1) / 10
    if (nmax > 1):
        for i in (N):
            i = int(i) + 1
            x.append(i)
            ecumul = 0
            for j in range(20):
                g = imp.gen_graphe(i, p)
                while (imp.is_empty(g)):
                    g = imp.gen_graphe(i, p)
                c2 = len(imp.glouton(g))
                c1 = len(imp.couplage(g))
                ecumul += abs(c2 - c1)
            y.append(ecumul / 20)
        return x, y
    else:
        print('nmax doit etre supérieur à 1')
        return None