Jump to content

Fazer Adjacência em Grafo em PROLOG


Go to solution Solved by crislanio_macedo,

Recommended Posts

Posted

Olá não tenho nenhuma experiência em prolog, e sei que este forum é de perl, contudo acredito que alguém aqui possa me ajudar.

tenho o seguinte código em prolog, e está dando erro.

aresta (a,b).
aresta (a,c).
aresta (b,d).
aresta (d,c).

adjacente (N, F) :- aresta (N, F).
adjacente (N, F) :- aresta (F, N).

está dando o seguinte erro,

?- ['Grafo.pl'].

ERROR: /home/crislanio/Área de Trabalho/Grafo.pl:1:7: Syntax error: Operator expected

true.

Att,

  • Solution
Posted
aresta(a,b).
aresta(b,f).
aresta(b,c).
aresta(c,d).
aresta(d,g).
aresta(f,h).
aresta(h,g).


adjacente(N, F) :- aresta(N, F) ;  aresta(F, N).

triangulo(X, Y, Z) :- adjacente(X,Y), adjacente(Y,Z).

resolvido, têm a questão do espaço.

Att

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.