From dc438d6d39c824b7fb5cbcfaefbb79e6932e2767 Mon Sep 17 00:00:00 2001 From: George Marchment <georgemarchment@yahoo.fr> Date: Thu, 10 Oct 2024 14:16:54 +0200 Subject: [PATCH] update the generation of the graphiz graphs -> by not considering edges in the subworkflows --- src/outils_graph.py | 51 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/src/outils_graph.py b/src/outils_graph.py index 5a4f5d6..3ba0f6d 100644 --- a/src/outils_graph.py +++ b/src/outils_graph.py @@ -15,7 +15,8 @@ def is_operation(node_id): return True return False -def fill_dot(dot, dico, label_node = True, label_edge = True): + +def add_nodes(dot, dico, label_node = True): for n in dico["nodes"]: try: color = n["color"] @@ -33,16 +34,64 @@ def fill_dot(dot, dico, label_node = True, label_edge = True): dot.node(n["id"], n["name"], shape=n["shape"], xlabel= xlabel, fillcolor=fillcolor, color = color, style="filled") else: dot.node(n["id"], n["name"], shape=n["shape"], fillcolor=fillcolor, color=color, style="filled") + + for sub in dico["subworkflows"]: + with dot.subgraph(name="cluster"+sub) as c: + add_nodes(c, dico["subworkflows"][sub], label_node = label_node) + c.attr(label=sub) + +def add_edges(dot, dico, label_edge = True): for e in dico["edges"]: if(label_edge): dot.edge(e['A'], e['B'], label= e['label']) else: dot.edge(e['A'], e['B']) + for sub in dico["subworkflows"]: with dot.subgraph(name="cluster"+sub) as c: + add_edges(dot, dico["subworkflows"][sub], label_edge = label_edge) + +def fill_dot(dot, dico, label_node = True, label_edge = True): + add_nodes(dot, dico, label_node = label_node) + add_edges(dot, dico, label_edge = label_edge) + + +def fill_dot_2(dot, dico, label_node = True, label_edge = True): + def add_nodes(dot, dico, label_node = True): + for n in dico["nodes"]: + try: + color = n["color"] + except: + color = "" + try: + xlabel = n["xlabel"] + except: + xlabel = "" + try: + fillcolor = n["fillcolor"] + except: + fillcolor = "" + if(label_node): + dot.node(n["id"], n["name"], shape=n["shape"], xlabel= xlabel, fillcolor=fillcolor, color = color, style="filled") + else: + dot.node(n["id"], n["name"], shape=n["shape"], fillcolor=fillcolor, color=color, style="filled") + add_nodes(dot, dico, label_node = label_node) + def add_edges(dot, dico, label_edge = True): + for e in dico["edges"]: + if(label_edge): + dot.edge(e['A'], e['B'], label= e['label']) + else: + dot.edge(e['A'], e['B']) + add_edges(dot, dico, label_edge = label_edge) + + for sub in dico["subworkflows"]: + with dot.subgraph(name="cluster"+sub) as c: + #add_nodes(c, dico["subworkflows"][sub], label_node = label_node) + #add_edges(dot, dico["subworkflows"][sub], label_edge = label_edge) fill_dot(c, dico["subworkflows"][sub], label_node, label_edge) c.attr(label=sub) + def generate_graph_dot(filename, dico, label_node = True, label_edge = True, render_graphs = True): dot = graphviz.Digraph(filename=filename, format='png', comment="temp") fill_dot(dot, dico, label_node, label_edge) -- GitLab