def Teste(): G = GrafoListaAdj(orientado = False) G.DefinirN(12) G.AdicionarAresta(1,7) G.AdicionarAresta(1,8) G.AdicionarAresta(1,9) G.AdicionarAresta(2,7) G.AdicionarAresta(2,8) G.AdicionarAresta(2,9) G.AdicionarAresta(3,7) G.AdicionarAresta(3,10) G.AdicionarAresta(3,11) G.AdicionarAresta(4,8) G.AdicionarAresta(5,10) G.AdicionarAresta(5,11) G.AdicionarAresta(5,12) G.AdicionarAresta(6,12) G.tV1 = 6 G.Desenhar("G.png") M = EmparelhamentoBipartido(G) for v in G.V(): if M[v] != None: for w_no in G.N(v, IterarSobreNo=True): if w_no.Viz == M[v]: G.DefinirAtrE(w_no, 'color=blue') G.Desenhar("G-M.png") print()
def LerGrafosTeste(): for num in range(1, 3): if num == 1: E = [(1, 2, 1), (2, 3, 2), (3, 4, 10), (3, 5, 3), (2, 6, 8), (6, 7, 7), (7, 8, 2), (7, 9, 2), (6, 10, 5), (10, 11, 3), (10, 12, 6), (10, 13, 1)] k = 3 else: E = [(1, 5, 4), (5, 6, 3), (2, 6, 2), (6, 7, 4), (3, 7, 5), (7, 4, 1)] k = 3 SP = 0 T = GrafoListaAdj(orientado=False) T.DefinirN(len(E) + 1) for (u, v, d) in E: e = T.AdicionarAresta(u, v) e.d = d SP = SP + d d = [None] * (T.n + 1) for i in range(1, T.n + 1): d[i] = [None] * (T.n + 1) for j in range(1, T.n + 1): d[i][j] = float("-inf") for v in T.V(): for no_u in T.N(v, IterarSobreNo=True): u = no_u.Viz d[v][u] = no_u.e.d d[u][v] = d[v][u] yield (T, d, k, SP)