def grau(g: Grafo, vert): N = g.N M = g.M contador = 0 for i in N: if g.existe_vertice(vert) and M[N.index(vert)][N.index( i)] != '-' and g.existe_aresta(vert + '-' + i): contador += M[N.index(vert)][N.index(i)] elif g.existe_vertice(vert) and M[N.index(i)][N.index( vert)] != '-' and g.existe_aresta(i + '-' + vert): contador += M[N.index(i)][N.index(vert)] return contador
def arestas_sobre_vertice(g: Grafo, vertice): M = g.M N = g.N lista = [] for i in range(len(M)): if g.existe_vertice(vertice) and M[i][N.index( vertice)] != '-' and M[i][N.index(vertice)] > 0: lista.append(vertice + '-' + N[i]) if g.existe_vertice(vertice) and M[N.index(vertice)][i] != '-' and M[ N.index(vertice)][i] > 0: lista.append(vertice + '-' + N[i]) return lista