Exemple #1
0
    static GRA_tpCondRet ExcluirAresta (GRA_tppGrafo grafo, tpVertice* v, tpVertice* u) {
        RemoverAresta(v, u);//mexe só em v, ou deveria       
        RemoverAresta(u, v);

        //BFS pra detectar se é necessário gerar nova componente.
        if (BFS(v,u) != 1) { //Estão em componentes distintas
            if (LIS_InserirElementoApos(grafo->componentes, u) != LIS_CondRetOK) {
                return GRA_CondRetFaltouMemoria;
            }
        }
        return GRA_CondRetOK;
    }   
Exemple #2
0
void RemoverAresta (Grafo* G, int v, int u, int eh_digrafo) {
    if (G == NULL) {                        ///***CONDITIONS***////
        printf("Grafo Invalido");           ///***CONDITIONS***////
    }
    if (v < 0 || u >= G->NV) {              ///***CONDITIONS***////
        printf("Arestas Invalidas");        ///***CONDITIONS***////
    }
    if (u < 0 || u >= G->NV) {              ///***CONDITIONS***////
        printf("Arestas Invalidas");        ///***CONDITIONS***////
    }

    int i = 0;
    while (i < G->grau[v] && G->arestas[v][i] != u)         //Go over the array and while it looks for a match
        i++;                                                //Increment variable i;
    if (i == G->grau[v])                                    // if I is equal to the max number of connections then
        printf("aresta inexistente");                       // there are no such edge

    G->grau[v]--;                                           //If there is, connections are lowered by one
    G->arestas[v][i] = G->arestas[v][G->grau[v]];           // Arrange the array
    if (eh_digrafo == 0) {
        RemoverAresta(G, u, v, 1);
    }
}