transitive-closure

SQL - Convert non-null adjacency list to path

爱⌒轻易说出口 提交于 2021-02-07 18:38:42
问题 I am working with some tables that represent a file system, and I need to select the full path of each folder as a flattened string. The first table lists the details of each folder: CREATE TABLE Folders( FolderID int IDENTITY(1,1) NOT NULL, [Name] nvarchar(255) NOT NULL) The second table lists transitive closures of folder relationships: CREATE TABLE FolderClosures( FolderClosuresID int IDENTITY(1,1) NOT NULL, AncestorFolderID int NOT NULL, --Foreign key to Folders.FolderID

JQ, convert CSV (parent child format) to JSON, another questions

泪湿孤枕 提交于 2021-01-07 02:56:56
问题 This is a continue of another post: JQ, convert CSV (parent child format) to JSON Hi, sorry to ask again. I tried to get the following format, without success. Really appreciate for some advice. I attach a picture to show how it looks like in a hierarchy view a picture to show in a hierarchy way, maybe it is easier. Hope it is possible ? *** CSV file ***** id,parent_id,size Subject,Null,1 analytics,Subject,1 cluster,analytics,1 AgglomerativeCluster,cluster,1 MergeEdge,cluster,2 animate

JQ, convert CSV (parent child format) to JSON, another questions

99封情书 提交于 2021-01-07 02:55:41
问题 This is a continue of another post: JQ, convert CSV (parent child format) to JSON Hi, sorry to ask again. I tried to get the following format, without success. Really appreciate for some advice. I attach a picture to show how it looks like in a hierarchy view a picture to show in a hierarchy way, maybe it is easier. Hope it is possible ? *** CSV file ***** id,parent_id,size Subject,Null,1 analytics,Subject,1 cluster,analytics,1 AgglomerativeCluster,cluster,1 MergeEdge,cluster,2 animate

Prolog. Construct a transitive closure of a graph

喜夏-厌秋 提交于 2020-12-12 05:09:32
问题 I'm very new to Prolog. I have such a graph: edge(a,e). edge(e,f). edge(f,d). edge(d,a). I define a transitive closure as: p(X,Y) :- edge(X,Y). tran(X,Z) :- p(X,Y), p(Y,Z). I need to construct a transitive closure of a graph. Please let me know how to proceed with it. 回答1: The problem with trans/2 is that it will only walk two edges, not an arbitrary number. We can define a predicate tran(X, Z) that holds if edge(X, Z) holds, or edge(X, Y) and then tran(Y, Z) . We thus in the latter follow

Transitive closure from a list using Haskell

岁酱吖の 提交于 2020-01-24 05:17:25
问题 I need to produce transitive closure on list using Haskell. So far I got this: import Data.List qq [] = [] qq [x] = [x] qq x = vv (sort x) vv (x:xs) = [x] ++ (member [x] [xs]) ++ (qq xs) member x [y] = [(x1, y2) | (x1, x2) <- x, (y1, y2) <- qq (y), x2 == y1] Output 1: *Main> qq [(1,2),(2,3),(3,4)] [(1,2),(1,3),(1,4),(2,3),(2,4),(3,4)] Output 2: *Main> qq [(1,2),(2,3),(3,1)] [(1,2),(1,3),(1,1),(2,3),(2,1),(3,1)] The problem is with second output. Instead of checking for additional transitive

Finding the transitive closure of a graph

十年热恋 提交于 2020-01-14 01:36:49
问题 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 connectivity matrix (=transitive closure?), that is different from the one in the picture: 01111 01111 01011 01111 01111 I have also tried using this applet which also gives me a different result: 01111 01111 01111 01111 01111 So I'm a little confused