directed-acyclic-graphs

DAG (Directed acyclic graph) - QAbstractItemModel

跟風遠走 提交于 2019-12-20 05:27:31
问题 I am planning on creating a Node Graph in pyqt. The abstract models that qt provides work for 1D, 2D and Tree data but the abstract class seems to break down for something like a node graph. In particular the "parent" function in QAbstractModel returns QModelIndex of a single parent. In a DAG I will may have multiple parents. One resource I found was this blog post: http://invalidmagic.wordpress.com/2009/12/10/qgraphicsscene-used-as-a-qabstractitemmodel/ It provides some useful information,

Combinatorics in Python

自闭症网瘾萝莉.ら 提交于 2019-12-19 03:16:29
问题 I have a sort of a one level tree structure as: Where p are parent nodes, c are child nodes and b are hypothetical branches. I want to find all combinations of branches under the constraint that only one parent can branch to only one child node, and two branches can not share parent and/or child. E.g. if combo is the set of combinations: combo[0] = [b[0], b[3]] combo[1] = [b[0], b[4]] combo[2] = [b[1], b[4]] combo[3] = [b[2], b[3]] I think that's all of them. =) How can this be achived

Javascript directed acyclic graph library? (Graph visualization is NOT necessary)

自古美人都是妖i 提交于 2019-12-18 13:22:20
问题 I have a dataset which is best represented by a graph. It consists of nodes of 6 or 7 different "types" with directed edges (dependencies on one another, guaranteed not to have cyclic dependencies). The dataset is essentially a template of a layered configuration, and the user needs to be able to select bits and pieces of the configuration from different layers which are desired, and have the dependent bits be brought in automatically. The general UI need is for a user to select or un-select

Algorithm for finding a Hamilton Path in a DAG

本秂侑毒 提交于 2019-12-18 10:34:25
问题 I am referring to Skienna's Book on Algorithms. The problem of testing whether a graph G contains a Hamiltonian path is NP-hard , where a Hamiltonian path P is a path that visits each vertex exactly once. There does not have to be an edge in G from the ending vertex to the starting vertex of P , unlike in the Hamiltonian cycle problem. Given a directed acyclic graph G ( DAG ), give an O(n + m) time algorithm to test whether or not it contains a Hamiltonian path. My approach, I am planning to

Relationship between BFS and topological sort

心不动则不痛 提交于 2019-12-18 05:06:23
问题 Topological sort can be done using both a DFS(having edges reversed) and also using a queue . A BFS can also be done using a queue . Is there any relationship between the way elements are stored and retrieved while using queue for a BFS to that when used a queue for topological sorting . Clarification will be helpful . Thanks. 回答1: No, there is not necessarily any relationship. I assume you are referring to the algorithm by Kahn from wikipedia/Topological_sorting#Algorithms, which wikipedia

Converting Directed Acyclic Graph (DAG) to tree

做~自己de王妃 提交于 2019-12-18 01:14:30
问题 I'm trying to implement algoritm to convert Directed Acyclic Graph to Tree (for fun, learining, kata, name it). So I come up with the data structure Node: /// <summary> /// Represeting a node in DAG or Tree /// </summary> /// <typeparam name="T">Value of the node</typeparam> public class Node<T> { /// <summary> /// creats a node with no child nodes /// </summary> /// <param name="value">Value of the node</param> public Node(T value) { Value = value; ChildNodes = new List<Node<T>>(); } ///

How to run Spark code in Airflow?

梦想的初衷 提交于 2019-12-17 22:06:06
问题 Hello people of the Earth! I'm using Airflow to schedule and run Spark tasks. All I found by this time is python DAGs that Airflow can manage. DAG example: spark_count_lines.py import logging from airflow import DAG from airflow.operators import PythonOperator from datetime import datetime args = { 'owner': 'airflow' , 'start_date': datetime(2016, 4, 17) , 'provide_context': True } dag = DAG( 'spark_count_lines' , start_date = datetime(2016, 4, 17) , schedule_interval = '@hourly' , default

How do I check if a directed graph is acyclic?

流过昼夜 提交于 2019-12-17 08:04:33
问题 How do I check if a directed graph is acyclic? And how is the algorithm called? I would appreciate a reference. 回答1: I would try to sort the graph topologically, and if you can't, then it has cycles. 回答2: Doing a simple depth-first-search is not good enough to find a cycle. It is possible to visit a node multiple times in a DFS without a cycle existing. Depending on where you start, you also might not visit the entire graph. You can check for cycles in a connected component of a graph as

How can you re-run upstream task if a downstream task fails in Airflow (using Sub Dags)

馋奶兔 提交于 2019-12-12 10:52:55
问题 I have an airflow dag that extracts data and performs validation. If the validation fails, it needs to re-run the extract. If the validation succeeds its continues. I've read people saying that sub dags can solve this problem, but I can't see any example of this. I've tried using a sub dag, but come across the same problem as trying to do it in one DAG. How can I get all tasks in the Sub DAG to re-run if one of them fails? I have the following DAG/sub dag details: maindag.py default_args = {

Directed Acyclic Graph with multi-parent nodes

余生长醉 提交于 2019-12-12 09:21:33
问题 Given: A directed acyclic graph with weighted edges, where a node can have multiple parents. Problem: For each child of root node, find a minimum-cost(sum of weights) path from such a child to some leaf which can be reached. A node can only be present in one such min-cost paths. Example graph: In the above graph, for node 2, all the available paths are: 2 -> 5 2 -> 1 -> 9 -> 6 2 -> 1 -> 10 -> 6 Among which 2 -> 1 -> 10 -> 6 has minimum cost of 3.5 Similarly, for node 4, all the available