Skip to content

Commit 1e5616e

Browse files
author
Hamid Gasmi
committed
#170 is updated
1 parent 2dcfcec commit 1e5616e

File tree

1 file changed

+10
-7
lines changed
  • 6-dynamic-programming-applications-in-machine-learning-and-genomics/1-sequence-alignment-1

1 file changed

+10
-7
lines changed

6-dynamic-programming-applications-in-machine-learning-and-genomics/1-sequence-alignment-1/longest_path_dag.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ def __init__(self, source, sink, edges):
1111
self.is_valid_dag = True
1212

1313
self.build_adjacency_list(edges)
14-
self.check_dag_dfs()
15-
14+
1615
#print(self.adjacency_list)
1716
#print("self.is_valid_source: ", self.is_valid_source)
1817
#print("self.is_valid_sink: ", self.is_valid_sink)
@@ -34,8 +33,6 @@ def build_adjacency_list(self, edges):
3433
self.is_valid_source &= (v != 0)
3534
self.is_valid_sink |= (v == self.vertices_count - 1)
3635

37-
#print(self.adjacency_list)
38-
3936
self.is_valid_source &= (len(self.adjacency_list[0]) > 0)
4037
self.is_valid_sink &= len(self.adjacency_list[self.vertices_count - 1]) == 0
4138

@@ -74,11 +71,17 @@ def compute_longest_path(self, source, sink):
7471
self.longest_path_len = 0
7572
self.longest_path = []
7673

74+
if not (self.is_valid_source and self.is_valid_sink):
75+
return
76+
77+
self.check_dag_dfs()
7778
if not self.is_valid_dag:
7879
return
80+
81+
longest_paths = [0 for _ in range(self.vertices_count)]
82+
#compute_longest_paths()
7983

80-
# TODO: your code here
81-
return ""
84+
8285

8386
def longest_path_to_str(self):
8487

@@ -94,4 +97,4 @@ def longest_path_to_str(self):
9497
dag.compute_longest_path(source, sink)
9598

9699
print(dag.longest_path_len)
97-
#print(dag.longest_path_to_str)
100+
print(dag.longest_path_to_str())

0 commit comments

Comments
 (0)