diff --git a/parse-ci.py b/parse-ci.py
index 5bb9bf12ba6f899523b63f36d1f357d8c30d5b90..1eabff168f707a5f0a75aae306f985d641688fcc 100644
--- a/parse-ci.py
+++ b/parse-ci.py
@@ -149,13 +149,58 @@ def get_stages(compile_info : list[job_data]) -> list[str]:
             stages.append(i.stage)
     return sorted(stages)
 
-def create_dot(compile_info : list[job_data]) -> None:
-    output = "digraph G {rankdir=\"LR\"\n"
+def add_to_dict(job_data, xdict) -> None:
+    location = job_data.location
+    parts = location.split('/')
+    current_dict = xdict
+    for part in parts[0:-1]:
+        if part not in current_dict:
+            current_dict[part] = {}
+        current_dict = current_dict[part]
+    current_dict[parts[-1]] = job_data
+
+def list_to_dict(compile_info : list[job_data]) -> dict:
+    output = {}
     for j in compile_info:
-        output = output + "\t" + j.location.replace('/', "_").replace('\\', "_").replace("-", "_").replace(".", "_") + "[label=\"" + j.location.replace('\\', '\\\\') + "\"]" ";\n"
-        for d in j.depends:
-             output = output + "\t\t" + d.replace('/', "_").replace('\\', "_").replace("-", "_").replace(".", "_") + " -> " + j.location.replace(os.sep, "_").replace("-", "_").replace(".", "_") + ";\n"
-    return output + "}"
+        add_to_dict(j, output)
+    return output
+
+def dict_to_nodes(dictionary) -> str:
+    if isinstance(dictionary, dict):
+        output_str = ""
+        for k in dictionary.keys():
+            if isinstance(dictionary[k], dict):
+                output_str += "\n\tsubgraph cluster_" + k + "{" + "\n\t\tlabel=\"" + k +  "\"" 
+                output_str += dict_to_nodes(dictionary[k]).replace('\n', "\n\t")
+                output_str += "\n\t}"
+            else:
+                output_str += "\n\t" + dictionary[k].location.replace('/', "_").replace('\\', "_").replace("-", "_").replace(".", "_") + "[label=\"" + dictionary[k].location.split('/')[-1] + "\"];"
+        return output_str
+    return ""
+
+def dict_to_edges(dictionary) -> str:
+    if isinstance(dictionary, dict):
+        output = ""
+        for k in dictionary.keys():
+            output += dict_to_edges(dictionary[k])
+        return output
+    if isinstance(dictionary, job_data):
+        job = dictionary
+        location = job.location
+        depends = job.depends
+        output_str = ""
+        for depend in depends:
+            d_location = depend
+            output_str += "\t" + d_location.replace('/', "_").replace('\\', "_").replace("-", "_").replace(".", "_") + " -> " + location.replace('/', "_").replace('\\', "_").replace("-", "_").replace(".", "_") + ";\n"
+        return output_str
+
+def create_dot(compile_info : list[job_data]) -> None:
+    dictionary = list_to_dict(compile_info)
+    output = "digraph G {rankdir=\"LR\""
+    output += dict_to_nodes(dictionary)
+    output += dict_to_edges(dictionary)
+    output += "}"
+    return output
 
 def generate_ci(compile_info : list[job_data]) -> str:
     output = ""