directed-acyclic-graphs

Shortest Path For A Dag

佐手、 提交于 2019-12-03 16:50:07
I have a graph with an s and t vertex that I need to find the shortest path between. The graph has a lot of special properties that I would like to capitalize on: The graph is a DAG (directed acyclic graph). I can create a topological sort in O(|V|) time, faster than the traditional O(|V + E|). Within the topological sort, s is the first item in the list and t is the last. I was told that once I have a topological sort of the vertices I could find the shortest path faster than my current standard of Dijkstra's Uniform Cost, but I cannot seem to find the algorithm for it. Pseudo code would be

Add a edge to direct acyclic graph with other restrictions

為{幸葍}努か 提交于 2019-12-03 16:36:48
I have a DAG. I have this operation to add a edge between two nodes. If A is reachable from B, then B is A's parent. If A is reachable from B without going though another node, then B is A's direct parent. Requirements for this graph are: No cycles. For any node, there is a list of direct parents P[1],P[2],P[3]... P[i] is not a parent of P[j] for any i and j. If adding a edge, requirement 1 is not met, the edge is not constructed. If adding a edge, requirement 2 is not met, the edge is constructed, but the direct parents will be modified in a way such that requirement 2 is met. For example,

Giving an example of a cycle in a directed graph

烈酒焚心 提交于 2019-12-03 15:45:25
I want an algorithm that gives one instance of a cycle in a directed graph if there is any. Can anyone show me a direction? In pseudo-code, or preferably, in Ruby? I previously asked a similar question , and following the suggestions there, I implemented Kahn's algorithm in Ruby that detects if a graph has a cycle, but I want not only whether it has a cycle, but also one possible instance of such cycle. example_graph = [[1, 2], [2, 3], [3, 4], [3, 5], [3, 6], [6, 2]] Kahn's algorithm def cyclic? graph ## The set of edges that have not been examined graph = graph.dup n, m = graph.transpose ##

Apache Airflow - trigger/schedule DAG rerun on completion (File Sensor)

风流意气都作罢 提交于 2019-12-03 14:42:42
Good Morning. I'm trying to setup a DAG too Watch/sense for a file to hit a network folder Process the file Archive the file Using the tutorials online and stackoverflow I have been able to come up with the following DAG and Operator that successfully achieves the objectives, however I would like the DAG to be rescheduled or rerun on completion so it starts watching/sensing for another file. I attempted to set a variable max_active_runs:1 and then a schedule_interval: timedelta(seconds=5) this yes reschedules the DAG but starts queuing task and locks the file. Any ideas welcome on how I could

Graphing the DAG generated by make?

限于喜欢 提交于 2019-12-03 12:30:27
问题 My understanding is that when make executes, it generates a DAG internally to represent all the dependencies in the project. Is there a way to get at that DAG and graph it, say using something like graphviz? I'm using gnu make on Ubuntu 8.04. EDIT I just ran across these tools called mamdag and mamdot. They're supposed to work with both nmake and gnu make, but I can't seem to find the options to get gnu make to spit out the mam file. It can be downloaded here - these packages: INIT ast-base

Generate a DAG from a poset using stricly functional programming

試著忘記壹切 提交于 2019-12-03 10:55:16
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 be to build a DAG that would represent the Hasse diagram of the sets, with edges representing

Representing a DAG (directed acyclic graph)

穿精又带淫゛_ 提交于 2019-12-03 09:16:52
问题 I need to store dependencies in a DAG. (We're mapping a new school curriculum at a very fine grained level) We're using rails 3 Considerations Wider than it is deep Very large I estimate 5-10 links per node. As the system grows this will increase. Many reads, few writes most common are lookups: dependencies of first and second degree searching/verifying dependencies I know SQL, I'll consider NoSQL. Looking for pointers to good comparisons of implementation options. Also interested in what we

How to derive FRP from Directed Acyclic Graphs?

狂风中的少年 提交于 2019-12-03 06:35:54
I am currently researching for my next project. This is in a pre-planning phase so this question is just to get an overview on existing technology. Setup I have a directed acyclic graph (DAG) with multiple inputs and output, think artificial neuronal network for now: The common way to process such a structure is to process the whole network on every (time-)step. I believe that is the method used by frp libraries such as netwire . Now I am in the fortunate position that I have a stream of events that each presents the change in one of the input nodes. The idea is that I probably don't have to

Seeking algorithm to invert (reverse? mirror? turn inside-out) a DAG

女生的网名这么多〃 提交于 2019-12-03 06:17:16
问题 I'm looking for an algorithm to "invert" (reverse? turn inside-out?) a DAG: A* # I can't ascii-art the arrows, so just / \ # pretend the slashes are all pointing B C # "down" (south-east or south-west) / / \ # e.g. G E D # A -> (B -> G, C -> (E -> F, D -> F)) \ / F The representation I'm using is immutable truly a DAG (there are no "parent" pointers). I'd like to traverse the graph in some fashion while building a "mirror image" graph with equivalent nodes, but with the direction of relations

Diff for Directed Acyclic Graphs

末鹿安然 提交于 2019-12-03 03:45:11
问题 I'm looking for an algorithm which can diff two Directed Acyclic Graphs(DAGs). That is, I'd like an algorithm which produces a sequence of deletions and insertions on the first DAG to produce the second DAG. I'm not a hundred percent sure, but I think a longest common subsequence can be applied to the DAGs. I'm less concerned about the length of the resulting edit sequence (as long as it's short enough) and more concerned about the running time of the algorithm. One complication is that none