Exemplo n.º 1
0
def is_biparti(G):
    X=[]
    Y=[]
    Visite=Vector.initVect(len(G),0)
    File=[]
    for i in range(1,len(G)):
        if Visite[i]==0:
            Visite[i]=1
            File.append(i)
            X.append(i)
            while len(File)!=0:
                 y=File.pop()
                 for z in G[y]:
                     if Visite[z]==0:
                         File.append(z)
                         if Visite[y]==1:
                             Visite[z]=2
                             Y.append(z)
                         else:
                             Visite[z]=1
                             X.append(z)
                     else:
                        if Visite[z]==Visite[y]:
                            return False
    return True,X,Y
Exemplo n.º 2
0
def is_cyclic(G):
    visite = Vector.initVect(len(G), False) 
    cyclic = [False]
    for y in range(0, len(G)):
        if not visite[y]: 
            cyclicRec(G, y, visite, cyclic)
        if cyclic[0]: 
            break 
    return cyclic[0]
Exemplo n.º 3
0
def profondG(G):
    Visite = Vector.initVect(len(G), 0)
    ordreVisite = []
    for i in range(1, len(G)):
        if Visite[i] == 0:
            ordreSousVisite = []
            profRec(G, i, Visite, ordreVisiteRec)
            ordreVisite.append(ordreVisiteRec)
    return ordreVisite
Exemplo n.º 4
0
def largeur(G, i):
    Visite = Vector.initVect(len(G), False) 
    File = [i] 
    ordreVisite = [] 
    Visite[i] = True  
    while len(File) != 0: 
        x = File[0] 
        File.pop(0)
        ordreVisite.append(x) 
        for succ in G[x]:
            if Visite[succ] == False: 
                Visite[succ] = True
                File.append(succ)
    return ordreVisite
Exemplo n.º 5
0
def largeurG(G):
    Visite = Vector.initVect(len(G), 0)
    ordreVisite = []
    File = []
    for i in range(1, len(G)):
        if Visite[i] == 0:
            ordreSousVisite = []
            File.append(i)
            Visite[i] = 1
            while File:
                y = File.pop(0)
                ordreSousVisite.append(y)
                for z in G[y]:
                    if Visite[z] == 0:
                        Visite[z] = 1
                        File.append(z)
                        else:
                        pass
            ordreVisite.append(ordreSousVisite)
    return ordreVisite
Exemplo n.º 6
0
def TCC(G,i):
    Visite = Vector.initVect(len(G), 0)
    ordreVisite = []
    prof = Vector.initVect(len(G), 0)
    profRec(G, i, Visite, ordreVisite, prof)
    return len(ordreVisite)
Exemplo n.º 7
0
def profond(G, i):
    Visite = Vector.initVect(len(G), 0)
    ordreVisite = []
    profRec(G, i, Visite, ordreVisite)
    return ordreVisite
Exemplo n.º 8
0
def degre(G):
    V = Vector.initVect((len(G)-1), 0)
    print(V)
    for sommet in range(1, len(G)):
        V[sommet-1]=deg(G, sommet)
    return V