Complement Graph - prolog -


i have question. have continuous undirected graph. , need code in prolog give me complementary graph.

for example graph:

edge(1,2). edge(2,3). edge(3,4). edge(4,5). edge(5,1).  rot(x,y):- edge(x,y). rot(x,y):- edge(y,x). 

please, :) thanks.

this should work issuing ground queries , enumerate possible edges.

complement(x, y):-   ((var(x);var(y)) -> setof(v, z^rot(v,z), vertices);true), % if either vertex not ground, compute set of vertices   (ground(x) -> (once(rot(x, _)), verticesx=[x]) ; verticesx=vertices), % determine list of candidate x   (ground(y) -> (once(rot(y, _)), verticesy=[y]) ; verticesy=vertices), % , candidate y   member(x, verticesx),   member(y, verticesy),   x \= y,        % generate , test   \+(rot(x,y)).  % possible candidates 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -