directed-acyclic-graphs

Finding the width of a directed acyclic graph… with only the ability to find parents

ぐ巨炮叔叔 提交于 2019-12-12 08:57:46
问题 I'm trying to find the width of a directed acyclic graph... as represented by an arbitrarily ordered list of nodes, without even an adjacency list. The graph/list is for a parallel GNU Make-like workflow manager that uses files as its criteria for execution order. Each node has a list of source files and target files. We have a hash table in place so that, given a file name, the node which produces it can be determined. In this way, we can figure out a node's parents by examining the nodes

Run DAG with tasks of different interval

大城市里の小女人 提交于 2019-12-11 18:19:04
问题 I have 3 tasks, A, B and C. I want to run task A only once, and then run task B monthly until end_date, then run task C only once to clean up. This is similar to this question, but not applicable. How to handle different task intervals on a single Dag in airflow? Thanks for your help 回答1: For task A that is supposed to run only once, you can take inspiration from here As far as tasks B & C are concerned, they can be tied up with A using a ShortCircuitOperator (as already told in the link you

if input edges has repeating subtrees, how to map a rooted directed acyclic graph (DAG) input as noded edges

和自甴很熟 提交于 2019-12-11 15:56:49
问题 a visual example of my valid tree structure is given below. as you see I have 2 p4 subtrees at level 2. level p1 0 /\ / \ / \ / \ / \ / \ / \ p2 p3 1 / \ / \ / \ / \ p4 c3 p4 c4 2 / \ / \ c1 c2 c1 c2 3 my initial input to represent the tree by edges is: $edges = [ [ 'pid' => 'p1', 'cid' => 'p2' ], [ 'pid' => 'p1', 'cid' => 'p3' ], [ 'pid' => 'p2', 'cid' => 'p4' ], [ 'pid' => 'p2', 'cid' => 'c3' ], [ 'pid' => 'p3', 'cid' => 'p4' ], [ 'pid' => 'p3', 'cid' => 'c4' ], [ 'pid' => 'p4', 'cid' =>

Closure Tables - Is this enough data to display a tree view?

瘦欲@ 提交于 2019-12-11 13:21:48
问题 Here is the table I have created by testing the closure table method. | id | parentId | childId | hops | | | | | 270 | 6 | 6 | 0 | 271 | 7 | 7 | 0 | 272 | 8 | 8 | 0 | 273 | 9 | 9 | 0 | 276 | 10 | 10 | 0 | 281 | 9 | 10 | 1 | 282 | 7 | 9 | 1 | 283 | 7 | 10 | 2 | 285 | 7 | 8 | 1 | 286 | 6 | 7 | 1 | 287 | 6 | 9 | 2 | 288 | 6 | 10 | 3 | 289 | 6 | 8 | 2 | 293 | 6 | 9 | 1 | 294 | 6 | 10 | 2 I am trying to create a simple tree of this using PHP. There does not seem to be enough data to create the

Optimization of an all-paths algorithm

会有一股神秘感。 提交于 2019-12-11 09:06:24
问题 I've been successful using the following algorithm to complete all-path data up to path length of 10 on graphs of ~900 nodes. However, I want to scale it up to larger graphs and I'm wondering if there are further optimizations I can do. So far I have: After a node has completed it's DFS the paths are saved to a hash table. Should said node be encountered, paths from the hash table are appended so work is not repeated. Nodes are sorted by their degree (highest first). This way nodes most

Finding all paths between two nodes on a DAG

喜夏-厌秋 提交于 2019-12-10 19:38:03
问题 I have a DAG that has the following adjacency list L | G, B, P G | P, I B | I P | I I | R R | \ I want to find all paths from L to R . I know that I have to do some kind of DFS, and this is what I have so far. (Excuse the Javascript) function dfs(G, start_vertex) { const fringe = [] const visited = new Set() const output = [] fringe.push(start_vertex) while (fringe.length != 0) { const vertex = fringe.pop() if (!visited.has(vertex)) { output.push(vertex) for (neighbor in G[vertex].neighbors)

What algorithm can I apply to this DAG?

六眼飞鱼酱① 提交于 2019-12-10 17:35:09
问题 I have a DAG representing a list of properties. These properties are such that if a>b, then a has a directed edge to b. It is transitive as well, so that if a>b and b>c, then a has a directed edge to c. However, the directed edge from a to c is superfluous because a has a directed edge to b and b has a directed edge to c. How can I prune all these superfluous edges? I was thinking of using a minimum spanning tree algorithm, but I'm not really sure what is the appropriate algorithm to apply in

Dijkstra's algorithm on directed acyclic graph with negative edges

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 09:11:56
问题 Will Dijkstra's algorithm work on a graph with negative edges if it is acyclic (DAG)? I think it would because since there are no cycles there cannot be a negative loop. Is there any other reason why this algorithm would fail? Thanks [midterm tomorrow] 回答1: Consider the graph (directed 1 -> 2, 2-> 4, 4 -> 3, 1 -> 3, 3 -> 5 ): 1---(2)---3--(2)--5 | | (3) (2) | | 2--(-10)--4 The minimum path is 1 - 2 - 4 - 3 - 5 , with cost -3 . However, Dijkstra will set d[3] = 2, d[2] = 3 in the first step,

Directed Acyclical Graph Traversal… help?

混江龙づ霸主 提交于 2019-12-09 12:28:31
问题 a little out of my depth here and need to phone a friend. I've got a directed acyclical graph I need to traverse and I'm stumbling into to graph theory for the first time. I've been reading a lot about it lately but unfortunately I don't have time to figure this out academically. Can someone give me a kick with some help as to how to process this tree? Here are the rules: there are n root nodes (I call them "sources") there are n end nodes source nodes carry a numeric value downstream nodes

Generate a DAG from a poset using stricly functional programming

南笙酒味 提交于 2019-12-09 08:33:50
问题 Here is my problem: I have a sequence S of (nonempty but possibly not distinct) sets s_i, and for each s_i need to know how many sets s_j in S (i ≠ j) are subsets of s_i. I also need incremental performance: once I have all my counts, I may replace one set s_i by some subset of s_i and update the counts incrementally. Performing all this using purely functional code would be a huge plus (I code in Scala). As set inclusion is a partial ordering, I thought the best way to solve my problem would