I am completely new to Prolog and was looking into graphs. I found a problem online that asks me to specify a node and then list all simple paths reachable from that node. There is no goal node, just try all possibilities and return all those…
I try to use the transitive_reduction of boost, but I don't know how to use it.
I have a graph defined with :
typedef boost::adjacency_list Graph;
typedef Graph::vertex_descriptor…
I have some program about a graph with black and white vertices:
black(root).
black(v1).
black(v3).
black(v4).
edge(root,root).
edge(v1,root).
edge(v2,v1).
edge(v3,v1).
edge(v4,v3).
edge(v5,v2).
edge(v5,v4).
edge(v6,v5).
vertex(X) :-…
I have a list of user facts defined as:
user(@michael).
user(@ana).
user(@bob).
user(@george).
user(@john).
and so on. Furthermore, I have a set of facts as:
follows(@michael,@ana).
follows(@ana,@bob).
follows(@bob,@michael).
I am trying to write…
I have this hypothetical program to check if a path exists from point A to B.
/*city rules*/
edge(phx, tuc).
edge(tuc, ccg).
edge(ccg, sf).
connected(C1, C2) :-
edge(C1, C2).
connected(C1, C2) :-
edge(C1, X),
connected(X, C2).
the…
this might be a simple problem but I need to do it differently.
The problem is that I have to find in prolog the possible routes of airflights.
I have this knowledge base
from_to(fresno,seattle).
from_to(fresno,albany). …
I need to define a predicate acyclic/1 that takes a graph in as input and determine if that graph is acyclic. So from my understanding
graph1(a,b).
graph1(b,c).
graph1(c,a).
Will return no and
graph2(a,b).
graph2(b,c).
will return yes
I…
I have read other similar questions and answers on this site, but can't seem to find the answer to my particular problem. I am trying to encode a maze in Prolog.
From region 0, you can move freely to regions 1 or region 3. From region 3, you can…
If I have a map with nodes 1,2,...,n, I want to know if I can go from n1 to n2, I can use the following code:
path(1,2).
path(3,5).
.....
get_to(A,B) :- path(A,B).
get_to(A,B) :- path(A,C),get_to(C,B).
But how can record the path from A to B and…
I need a recursive function that finds all blood relatives in a family tree. But I honestly have no idea how to implement this in Prolog.
My current understanding for a solution, would be to search the current branch for a match and proceed to the…
I cannot figure out why the following query from the given Prolog code generates the error Out of local stack.
Prolog code:
likes(g,c).
likes(c,a).
likes(c,b).
likes(b,a).
likes(b,d).
likes(X,Z) :- likes(X,Y), likes(Y,Z).
the query
?-…
I'm trying to determine that shape of a directed graph by solving constraints on presence of nodes and arcs, e.g., binary variable V1V2 is 1 if there is an arc from node V1 to V2. I would like to express the reachability constraint (or,…
Context, first. I have the following bi-directional graph.
Represented in Prolog like this:
relation(a,c).
relation(b,d).
relation(c,d).
relation(d,e).
relation(e,f).
connection(X,Y) :- relation(X,Y).
connection(X,Y) :- relation(Y,X).
So I have…
My multiple solution problem arises due to Prolog's backtracking looping through the goals. Whilst I understand that, technically, each solution provided is correct, it is not useful to me. Is there a method to remove duplicates?
Here is my code so…
I have my data of pairwise DNA sequences showing similarity in the following way..
AATGCTA|1 AATCGTA|2
AATCGTA|2 AATGGTA|3
AATGGTA|3 AATGGTT|8
TTTGGTA|4 ATTGGTA|5
ATTGGTA|5 CCTGGTA|9
CCCGGTA|6 GCCGGTA|7
GGCGGTA|10 AATCGTA|2
GGCGGTA|10 …