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
2
votes
1 answer

Finding the transitive closure of a graph

I am trying to calculate a transitive closure of a graph. Let`s consider this graph as an example (the picture depicts the graph, its adjacency and connectivity matrix): Using Warshall's algorithm, which i found on this page, I generate this…
TheAptKid
  • 1,559
  • 3
  • 25
  • 47
1
vote
2 answers

Compute clusters (transitive closure) on a bidirectional cyclic graph in Snowflake SQL

I have a bi-directional graph containing multiple clusters and non-trivial cycles, i.e. the graph contains cycles involving 3 or more nodes. The graph is represented as an edge table and the list of nodes is the set of unique nodes listed in the…
1
vote
1 answer

Possibility of speeding up transitive closure list updater

I have created the following function: update_list3 = function(identity_dict){ suppressMessages(suppressWarnings({ library(ggm) #adjacency matrix g = matrix(unlist(lapply(identity_dict, FUN = function(x){ b =…
ABuist
  • 31
  • 2
1
vote
1 answer

Prolog issue about searching all possible paths

I am new in Prolog. I am trying to develop a Program which goal is, given the X,Y coordinate of a trophy (specified in the fact trofeo(4,3)), and the coordinates of some obstacles (specified in the fact ostacolo(,)), the Program has to find the…
MN1005
  • 11
  • 2
1
vote
2 answers

how to find all connected path from node to another node using prolog?

how can i find all path of node that are connected between : a to g by using rules on Prolog ? The graph my simple…
1
vote
1 answer

Procedure for reducing the density of a directed graph

I have a complete weighted directed graph G=(V,A,W) and I want to reduce the density of the graph by deleting arcs as follows: given i,j,k \in V if w(i,j)+w(j,k) <= w(i,k), then we delete arc (i,k). The code is given below, where ad is initially the…
1
vote
1 answer

Excel power query - aggregate continuous "transitive" overlapping time intervals

I'm trying to aggregate the below given table 1 to table 2 with Excel power queries. The goal is to merge continuous time intervals of the same group into a single row. For direct overlappings like event 5 and 6 this was quite easy. But this…
user2653422
  • 1,095
  • 1
  • 12
  • 18
1
vote
1 answer

swi-ProLog Finding all possible starting nodes which can arrive specific ending node

I am new to logic programming. I am trying to write a program which can find all nodes which can reach to an specific node. Here is my code: link(0, 1). link(3, 4). link(1, 2). link(2, 0). link(2, 1). link(3, 2). link(4, 3). So show above…
SwainG
  • 19
  • 6
1
vote
1 answer

Transitive closure

I want to create a TransitiveClosure() function in python that can input a dictionary and output a new dictionary of the transitive closure. for example R = {1: [3], 2: [4], 3: [], 4: [1]} will output R R = {1 : [3], 2 : [1, 3, 4], 3 : [], 4 : [1,…
1
vote
2 answers

Prolog query not terminating

This is a very basic query, but I'm new to prolog and have trouble finding why this query does not terminate: % fact progeny(dexter, mark). progeny(mark, bill). progeny(bill, lisa). % rule progeny(X, Y) :- progeny(X, Z), progeny(Z, Y). The…
No_Name
  • 155
  • 2
  • 14
1
vote
2 answers

Precompute transitive closure of a relation in MiniZinc: Y/N?

I am trying to solve an exercise in MiniZinc in which a partial ordering relation is given by a 2-D array: enum NODE = { A, B, C, D, E }; int : SOURCE = 1; int : TARGET = 2; array[int,1..2] of NODE: edge = [| A, B % edge 1, source & edge…
David Tonhofer
  • 14,559
  • 5
  • 55
  • 51
1
vote
1 answer

How to get the not effect in Prolog

I am trying to create a rule that recursively calls itself, and finds all possible paths to traverse a directed graph. I am using a findall() to do so. The functions is traverse(Start,End). I have: traverse(Start,End,[li]) :- node(Start,End), …
1
vote
1 answer

Convert a list from findall predicate to a string prolog

I am struggling to identify a way to convert a list to string. This list is the output from a findall predicate. see below my code. edge(a,b). edge(a,c). edge(b,c). edge(c,d). edge(c,e). edge(d,e). edge(f,g). edge(g,h). route(X, Z, []) :- …
mkpisk
  • 152
  • 1
  • 9
1
vote
1 answer

How to express "ancestor" recursively

I'm stuck with this recursion which doesn't work as I expect. Where is my mistake? #!/usr/bin/prolog % Facts mother( jeanne , michel ). % great-grandmother, grandfather mother( genevieve, aubin ). % grandmother, father mother( irene ,…
Aubin
  • 14,617
  • 9
  • 61
  • 84
1
vote
1 answer

Having trouble thinking in prolog. Infinite recursion problem

In reading a book on prolog I have come across trouble with this problem. % Write a predicate travel_to/2 which determines whether it is possible to % travel from one place to another by chaining together car, train, and % plane journeys. For…
Nicholas Hubbard
  • 527
  • 2
  • 15