Algorithm to find lowest common ancestor in directed acyclic graph?

Den Roman’s link (Archived version) seems promising, but it seemed a little bit complicated to me, so I tried another approach. Here is a simple algorithm I used: Let say you want to compute LCA(x,y) with x and y two nodes. Each node must have a value color and count, resp. initialized to white and … Read more

Algorithm for finding a Hamiltonian Path in a DAG

You can first topologically sort the DAG (every DAG can be topologically sorted) in O(n+m). Once this is done, you know that edge go from lower index vertices to higher. This means that there exists a Hamiltonian path if and only if there are edge between consecutive vertices, e.g. (1,2), (2,3), …, (n-1,n). (This is … Read more

How to run Spark code in Airflow?

You should be able to use BashOperator. Keeping the rest of your code as is, import required class and system packages: from airflow.operators.bash_operator import BashOperator import os import sys set required paths: os.environ[‘SPARK_HOME’] = ‘/path/to/spark/root’ sys.path.append(os.path.join(os.environ[‘SPARK_HOME’], ‘bin’)) and add operator: spark_task = BashOperator( task_id=’spark_java’, bash_command=’spark-submit –class {{ params.class }} {{ params.jar }}’, params={‘class’: ‘MainClassName’, ‘jar’: … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)