diff --git a/src/graph.py b/src/graph.py
index 6be771ce09be2957d0f6747148957634f4d49fa7..8329f044bb947bd9f2269e4ed3a222c26d26f3a1 100644
--- a/src/graph.py
+++ b/src/graph.py
@@ -84,11 +84,11 @@ class Graph():
                 node_id = get_node_id(self.full_dico, process)
                 remove_node(self.full_dico, node_id)
 
-
-            self.get_dependency_graph()
+            #self.get_dependency_graph()
             self.intialise_process_dependency_graph()
 
-            
+
+        
             #self.networkX_wo_operations = self.get_networkx_graph(self.dico_process_dependency_graph, self.networkX_wo_operations)
             self.dico_flattened["nodes"] = []
             self.dico_flattened["edges"] = []
@@ -159,7 +159,7 @@ class Graph():
         generate_graph(self.get_output_dir()/'graphs'/filename, graph_dico_wo_orphan_operations(self.full_dico), label_edge=False, label_node=False, render_graphs = render_graphs)
 
 
-    def intialise_process_dependency_graph(self):
+    def intialise_process_dependency_graph(self):        
         self.intia_link_dico()
 
         #Function that replicates the workflow's structure wo the operations in the nodes
@@ -175,33 +175,64 @@ class Graph():
                 dico['subworkflows'][sub] = replicate_dico_process_dependency_graphs(dico_struct['subworkflows'][sub])
             return dico
 
+        
         dico = replicate_dico_process_dependency_graphs(self.full_dico)
 
+
+        
         #This is a dictionnary which links every node to it's connected process
+        #node_2_processes = copy.deepcopy(self.link_dico)
+        #already_searched = {}
+        #for nodeA in node_2_processes:
+        #    already_searched[nodeA] = [nodeA]
+        #changed = True
+        #while(changed):
+        #    changed = False
+        #    for nodeA in node_2_processes:
+        #        temp = node_2_processes[nodeA].copy()
+        #        for give in node_2_processes[nodeA]:
+        #            if(is_operation(give)):
+        #                temp.remove(give)
+        #                if(nodeA!=give and give not in already_searched[nodeA]):
+        #                    already_searched[nodeA] += give
+        #                    temp_temp = node_2_processes[give]
+        #                    for node_temp in already_searched[nodeA]:
+        #                        try:
+        #                            temp_temp.remove(node_temp)
+        #                        except:
+        #                            None
+        #                    temp+=temp_temp
+        #                    changed = True
+        #        node_2_processes[nodeA] = list(set(temp))
+        #print(node_2_processes)
+
+        
+        topological_order = topological_sort(self.link_dico)
+        #topological_order.reverse()
         node_2_processes = copy.deepcopy(self.link_dico)
-        already_searched = {}
-        for nodeA in node_2_processes:
-            already_searched[nodeA] = [nodeA]
-        changed = True
-        while(changed):
-            changed = False
-            for nodeA in node_2_processes:
-                temp = node_2_processes[nodeA].copy()
-                for give in node_2_processes[nodeA]:
-                    if(is_operation(give)):
-                        temp.remove(give)
-                        if(nodeA!=give and give not in already_searched[nodeA]):
-                            already_searched[nodeA] += give
-                            temp_temp = node_2_processes[give]
-                            for node_temp in already_searched[nodeA]:
-                                try:
-                                    temp_temp.remove(node_temp)
-                                except:
-                                    None
-                            temp+=temp_temp
-                            changed = True
-                node_2_processes[nodeA] = list(set(temp))
+        for i in [len(topological_order)-1-x for x in range(len(topological_order))]:
+            updating = topological_order[i]
+            for y in [len(topological_order)-1-x for x in range(len(topological_order))]:
+                if(y>i):
+                    fixed = topological_order[y]
+                    if(is_operation(fixed)):
+                        if(fixed in node_2_processes[updating]):
+                            node_2_processes[updating]+=node_2_processes[fixed].copy()
+            node_2_processes[updating] = list(set(node_2_processes[updating]))
+            tab = []
+            for give in node_2_processes[updating]:
+                if(is_process(give)):
+                    tab.append(give)
+                #if(is_operation(give)):
+                #    node_2_processes[updating].remove(give)
+                #else:
+                #    print("**", give)
+            node_2_processes[updating] = tab
+
 
+
+
+        
         #Getting the dico of paths in the workflow
         path_from_process_to_other_processes = {}
         searching = True
@@ -229,7 +260,6 @@ class Graph():
             timeout+=1
         if(timeout>=constant.WHILE_UPPER_BOUND):
             raise BioFlowInsightError(f"The WHILE_UPPER_BOUND was exceeded. BioFlow-Insight was unable to create the dico of paths.", type="Unable to create the dico of paths")
-            
 
         #%2x%2x%2x
         colours = ["#ffbe00", "#0055c8", "#6e6e00", "#a0006e", "#ff5a00", "#82dc73", "#ff82b4", "#d282be", "#d2d200", "#dc9600", "#6e491e", "#00643c", "#82c8e6", "#640082"]
@@ -285,6 +315,7 @@ class Graph():
             for sub in dico['subworkflows']:
                 add_edges_flow_edges(dico["subworkflows"][sub], added_in_condition) 
             
+        
         #if(self.workflow.get_duplicate_status()):
         if(False):#Right now not generating the colored edges
             checking_conditions = True
@@ -304,7 +335,6 @@ class Graph():
         else:
             add_edges(dico, condition="", checking_conditions=False)
 
-
         self.dico_process_dependency_graph = dico
 
         with open(f"{self.get_output_dir()}/graphs/process_dependency_graph.json", 'w') as output_file :