I am developing a path finding algorithm in Prolog, giving all nodes accessible by a path from a starting node. To avoid duplicate paths, visited nodes are kept in a list.
Nodes and neighbors are defined as…
I have a big structure with items and relations between the items.
I need to find all transitive relations for all items. I duplicate all links and use transitive closure. E.g.:
A --- B --- C E --- F --- G
|
|
D
As a result I…
I am attempting to traverse a graph I have constructed in prolog. The Graph is represent as a list of transitions of the form:
next(FromState, ToState, Symbol) where FromState and ToState are nodes of the graph that are represented as:…
I have the following graph:
My goal is to get all the direct connections of a certain node and all of the nodes that are not connected with a certain node for example:
connections(1,X).
X=3;
X=4;
X=5;
X=6.
noConnections(1,X).
X=2.
This is my…
I have a data frame like below.
dat <- data.frame(v1=c("a","b","c","c","a","w","f"),
v2=c("z","a","a","w","p","e","h"))
v1 v2
1 a z
2 b a
3 c a
4 c w
5 a p
6 w e
7 f h
I want to add a group column based on whether…
I was wondering what the best way to compute the transitive closure of an undirected graph in the python library graph_tool is.
My solution so far is to create a directed graph from the original one and use the transitive_closure method on that:
…
I am looking for a way to return both the parent and child in a transitive SPARQL query, and only the relations that make up the path.
The following query returns the parents and intermediate object pairs leading up to http://example.com/child, but…
Is it possible to guarantee that the results of a transitive query in SPARQL come back in the order in which they were walked?
So, given some simple data:
ex:contains …
I have a very simple program in swipl
edge(X,Y) :- edge(X,Z),edge(Z,Y).
edge(a,b).
edge(a,f).
edge(b,c).
edge(c,d).
edge(g,c).
edge(f,g).
edge(f,c).
edge(f,e).
edge(c,e).
edge(e,d).
But when Ι make a query edge(a,c). Ι get a Out of local stack…
My intention was to implement a simple example (just for myself) of transitivity in Prolog.
These are my facts:
trust_direct(p1, p2).
trust_direct(p1, p3).
trust_direct(p2, p4).
trust_direct(p2, p5).
trust_direct(p5, p6).
trust_direct(p6,…
can someone please elaborate upon the functionality/conditions of travel(A,B,Visited,Path) and travel(A,B,P,[B|P]) .. this code finds the path between path A and B in a graph…
A few months ago, I had taken part in a contest on CodeForces, and I've been trying different solutions to solve it since.
The problem basically consists of inputs containing nodes and edges of a directed graph. Basically, if: A is pointing to B,…
I'm trying to solve this Pebble Solitaire problem, and this is part of my code:
% Base case
play(List, X) :-
count_pebbles(List, X).
%%%%%%%%%%%%%%
% JUMP RIGHT %
%%%%%%%%%%%%%%
% oo-XXXXXXXXX
play( [111, 111, 45|Tail], X) :-
…