Skip to content

Instantly share code, notes, and snippets.

@LucasMW
Created October 31, 2014 13:37
Show Gist options
  • Save LucasMW/5c372049f45f7969a8a6 to your computer and use it in GitHub Desktop.
Save LucasMW/5c372049f45f7969a8a6 to your computer and use it in GitHub Desktop.
GRA_ExisteCaminho . Retorna se existe ou não caminho entre os vértices ditos
GRA_tpCondRet GRA_ExisteCaminho(GRA_tppGrafo grafo, int noInicioId, int noFimId)
{
int* ptrIds;
int tam;
int i;
GRA_tpCondRet ret;
ret=GRA_DFS(grafo,&ptrIds,&tam,noInicioId);
if(ret!=GRA_CondRetOK)
return ret;
for(i=0;i<tam;i++)
{
if(ptrIds[i]==noFimId)
return GRA_CondRetCaminhoExiste;
}
return GRA_CondRetCaminhoNaoExiste;
}
/***********************************************************************
*
* $FC Função: GRA &ExisteCaminho
*
* $ED Descrição da função
* Esta função verifica se existe caminho entre dois vértices
* cujos ids são informados, de um determinado grafo.
*
* $EP Parâmetros
* grafo - ponteiro para a cabeça do grafo a ser impresso
* noInicioId - Id do vértice pelo qual se começa
* noFimId - Id do vértice ao qual se chega
* $FV Valor retornado
* Se o caminho for encontrado retornará GRA_CondRetCaminhoExiste
* Se o caminho não for encontrado retornará GRA_CondRetCaminhoNaoExiste
* Se o grafo for vazio retornará GRA_CondRetGrafoVazio.
* Se o vértice inicial não existir retornará GRA_CondRetNoNaoExiste.
*
*
***********************************************************************/
GRA_tpCondRet GRA_ExisteCaminho(GRA_tppGrafo grafo, int noInicioId, int noFimId);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment