Questions tagged [transitive-closure]

Use this tag for the transitive closure of a relationship or when related to graph theory.

References:

Wikipedia
Wolfram MathWorld

148 questions
1
vote
1 answer

Results are not compareing with given facts

Using prolog make a code to get some compared outputs but some outputs not working properly. seems those are not comparing with facts. here the code fact(Fact) :- Fact,!. fact(Fact):-Fact = ..[Rel, Arg1, Arg2],isa(Arg1, SuperArg). SuperFact…
Chara
  • 31
  • 10
1
vote
1 answer

Determine if nodes are connected in matrix in Prolog

So what I get is a list that contains coordinates in a matrix. For example: List 1: [[1, 1], [2, 1], [3, 1], [4, 1], [2, 2], [1, 3], [2, 3], [3, 3], [4, 3]] List 2: [[1, 1], [2, 1], [3, 1], [4, 1], [1, 3], [2, 3], [3‚3], [4, 3]] I need to figure…
Zahand
  • 490
  • 3
  • 12
  • 23
1
vote
1 answer

Recursion in Prolog and more

I have this knowledgebase in prolog of a air company and their flighs: flight(departure,arrive,day). flight(london,paris,monday). flight(paris,barcelona,thursday). flight(paris,madrid,sunday). flight(madrid,lisbon,saturday). recursive…
cdiogo7
  • 57
  • 7
1
vote
1 answer

Labelling groups of two columns in SQL (BigQuery SQL if possible)

Given a table name ip A = |A 1 | |B 1 | |C 1 | |B 2 | |C 2 | |D 3 | |E 2 | If any two names share same ip they belong in same group. Also ip with same name belong in same group. If…
cgnorthcutt
  • 3,890
  • 34
  • 41
1
vote
1 answer

Writing prolog with recursive rules? "ERROR: Out of local stack"

Given facts such as: Jake is smarter than Nik Nik is smarter than Wes Wes is smarter than Dik Write a recursive program that will determine that Jake's is smarter than Dik's. The solution that I have is: smarter(jake, nik). smarter(nik,…
Cael
  • 556
  • 1
  • 10
  • 36
1
vote
1 answer

prolog out of local stack using lists

i have to find route between two states and ive reached here and i am having error as of now regarding out of stack help me % state 1 is border of state 2 % borders(A , B). borders(sasktchewan, alberta). borders(saskatchewan,…
user4596514
1
vote
1 answer

Find if there is a connection between two places and calculate cost

i have connections between cities like connection(London,Sziget). connection(Sziget,Kairo). so i want to create a predicate to find if there is a possible route between two cities even passing through other cities first. Input example:…
cavla
  • 118
  • 3
  • 11
1
vote
1 answer

Prolog: Finding path in a maze

Let's say we have a robot that is on a Chess Board and can move like a King can. The board is with coords from [1,1] to [8,8]. The starting position is [1,1] the final is [8,8]. There is a list X that contains lists of obstacle's coords for example…
chnging
  • 746
  • 1
  • 8
  • 27
1
vote
1 answer

Warshall's Algorithm implemented with Stored Procedure

I've implemented Warshall's algorithm in a MySQL Stored Procedure. Unfortunately the procedure takes a long time to complete. I'm a beginner in writing Stored Procedures, do you know what I can do, to make it faster? Brief explanation: I'm trying to…
1
vote
1 answer

advice on commutative and transitive equivalence implementation‏ in Prolog

I'd like to simulate the equivalence in Prolog with the properties of being commutative and transitive, here is what I did: equal/2 will be supplying as facts. symmetricEqual(A,B):- equal(A,B). symmetricEqual(A,B):-…
user1935724
  • 554
  • 1
  • 6
  • 18
0
votes
1 answer

boost::transitive_closure() and "error: no matching function for call to ‘vertices(const std::vector..."

I'm using GCC 4.5.0 with boost 1.48.0 on a Linux machine. While compiling a source file that uses the boost::transitive_closure() function from boost::graph I'm encountering the same problem as in…
Jacob
  • 1
  • 3
0
votes
0 answers

From CTE to mySQL stored procedure code

This is a query using sql CTE's to create a transitive closure of a table containing relations between users.(edges of a graph). How can this be done in mySQL? WITH RECURSIVE transitive_closure(a, b, distance, path_string) AS ( SELECT a, b, 1 AS…
0
votes
2 answers

Complete recursive transitive dependencies per row in pandas dataframe

Here is a simple program that transitively maps sets of columns: import pandas as pd df1vals = [{'c1': '1', 'c2': "2"}] df1 = pd.DataFrame(df1vals, columns = ['c1' , 'c2']) df2vals = [{'c2': '2', 'c3': "100"}] df2 = pd.DataFrame(df2vals, columns =…
Jeremy
  • 5,365
  • 14
  • 51
  • 80
0
votes
0 answers

Cannot query the transitive closure of a property with Snap SPARQL Query in Protege and Ordering of results in the SPARQL query

Using the Snap SPARQL Query view I do not find a way to query the transitive closure e.g. of the property ex:myontology#isPartOf so that I can infer that, since A isPartOf AB which isPartOf ABC which isPartOf ABCD then A isPartOf ABC and ABCD. Any…
nik
  • 1
  • 1
0
votes
1 answer

Transitive closure: should it include the null transition?

I'm trying to design a general purpose transitive closure implementation: find all the nodes in a graph reachable in one or more steps from a given start node. Or should it be zero or more steps? That is, should the result automatically include the…
Michael Kay
  • 156,231
  • 11
  • 92
  • 164