diff --git a/src/graph.py b/src/graph.py
index e397f2af066d2e82d4fc405922d6d695950a22a2..7252cb32fac66539d67797dc9c53c127f2a37663 100644
--- a/src/graph.py
+++ b/src/graph.py
@@ -294,9 +294,10 @@ class Graph():
         self.initialise_flattened_dico(self.dico_process_dependency_graph)
         dico = self.dico_flattened
 
-        relev_user_view_builder(dico, relevant_modules=relevant_processes)
-
-        #generate_graph(self.get_output_dir()/'graphs'/"temp", dico, label_edge=True, label_node=True, render_graphs = render_graphs)
+        user_view = relev_user_view_builder(dico, relevant_modules=relevant_processes)
+        with open(self.get_output_dir()/ "graphs/user_view.json", 'w') as output_file :
+            json.dump(user_view, output_file, indent=4)
+        generate_graph(self.get_output_dir()/'graphs'/"user_view", user_view, label_edge=True, label_node=True, render_graphs = render_graphs)
         
 
 
diff --git a/src/outils_graph.py b/src/outils_graph.py
index 4e9b3ecad3e42aff32cecf102abb84ca1e6832f1..fc5d4c67f458e8842ee3abaf2e30779eb8873009 100644
--- a/src/outils_graph.py
+++ b/src/outils_graph.py
@@ -515,6 +515,20 @@ def get_names_tab(dico, tab):
         final.append(names)
     return final
 
+def get_name_new_node(new_nodes, relevant_modules):
+    for r in relevant_modules:
+        if([r] in new_nodes):
+            return r
+    #Arbitrary choice of choosing the name with the longest name
+    longest_name = new_nodes[0][0]
+    for name in new_nodes:
+        if(len(longest_name)<len(name[0])):
+            longest_name = name[0]
+    return longest_name
+
+def check_same_elements(list1, list2):
+    return set(list1)==set(list2)
+
 def relev_user_view_builder(dico, relevant_modules):
     R = []
     for r in relevant_modules:
@@ -526,7 +540,7 @@ def relev_user_view_builder(dico, relevant_modules):
     for out in outputs:
         dico["edges"].append({'A':out, 'B':'output'})
     #TODO remove this -> it's to replicate the one in the algortihm demo
-    dico["edges"].append({'A':get_id_from_name(dico, "M5")[0], 'B':'output'})
+    #dico["edges"].append({'A':get_id_from_name(dico, "M5")[0], 'B':'output'})
     for input in inputs:
         dico["edges"].append({'A':"input", 'B':input})
     U = []
@@ -560,15 +574,13 @@ def relev_user_view_builder(dico, relevant_modules):
     #Line 10
     for r in R:
         M = set([r]).union(set(in_r[r])).union(set(out_r[r]))
-        U = set(U).union(M)
+        U.append(list(M)) 
     #Step 2
     NRC = []
     for n in set(N) - set(R):
         if(marked_statues[n] == 'unmarked'):
             def condition_line_13(NRC, n, dico, R, inputs, outputs):
-                def check_same_elements(list1, list2):
-                    return set(list1)==set(list2)
-                #Ms = generate_subsets(NRC)
+                
                 for i in range(len(NRC)):
                     M = NRC[i]
                     if(check_same_elements(rPredM(M, dico, R, ["input"]), rPred(n, dico, R, ["input"])) and
@@ -584,9 +596,8 @@ def relev_user_view_builder(dico, relevant_modules):
             else:
                 M = [n]
                 NRC.append(M)
-    print(get_names_tab(dico, NRC))
+    #print(get_names_tab(dico, NRC))
     
-    1/0
     #Step 3
     changes_in_NRC = True
     while(changes_in_NRC):
@@ -604,19 +615,47 @@ def relev_user_view_builder(dico, relevant_modules):
                     #Line 23 
                     condition_left, condition_right = True, True
                     for n in V_plus:
-                        if(rPred(n, dico, R, ['input'])!=rPredM(M, dico, R, ["input"])):
+                        if(not check_same_elements(rPred(n, dico, R, ['input']), rPredM(M, dico, R, ["input"]))):
                             condition_left = False
                     for n in V_minus:
-                        if(rSucc(n, dico, R, ['output'])!=rSuccM(M, dico, R, ["output"])):
+                        if(not check_same_elements(rSucc(n, dico, R, ['output']), rSuccM(M, dico, R, ["output"]))):
                             condition_left = False
                     if(condition_left and condition_right):
                         NRC.remove(M1)
                         NRC.remove(M2)
                         NRC.append(M)
                         changes_in_NRC = True
-    tab = list(U)+NRC
-    print(tab)
-    print(get_names_tab(dico, tab))
-    return 
+    new_nodes = list(U)+NRC
+
+    new_dico = {}
+    new_dico["nodes"] = []
+    new_dico["edges"] = []
+    new_dico["subworkflows"] = []
+    for i in range(len(new_nodes)):
+        new_nodes[i].sort()
+        node = {"id": ''.join(new_nodes[i]).replace('<', '').replace('>', ''),
+                "name": get_name_new_node(get_names_tab(dico, new_nodes[i]), relevant_modules),
+                "shape": "ellipse",
+                "xlabel": "",
+                "fillcolor": ""}
+        new_dico["nodes"].append(node)
+    added_edges = []
+    for edge in dico["edges"]:
+        for i in range(len(new_dico["nodes"])):
+            nA = new_dico["nodes"][i]
+            for y in range(len(new_dico["nodes"])):
+                if(i!=y):
+                    nB = new_dico["nodes"][y]
+                    edge_string = f'{nA["id"]}->{nB["id"]}'
+                    if(edge["A"].replace('<', '').replace('>', '') in nA["id"] 
+                       and edge["B"].replace('<', '').replace('>', '') in nB["id"]
+                       and edge_string not in added_edges):#So we don't have dupliacte edges
+                        new_dico["edges"].append({
+                            "A": nA["id"],
+                            "B": nB["id"],
+                            "label": ""
+                            })
+                        added_edges.append(edge_string)
+    return new_dico