graph: make graphviz export more readable

Message ID 20240828134226.866655-2-rjarry@redhat.com (mailing list archive)
State Accepted
Delegated to: David Marchand
Headers
Series graph: make graphviz export more readable |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS

Commit Message

Robin Jarry Aug. 28, 2024, 1:42 p.m. UTC
Change the color of arrows leading to sink nodes to dark orange. Remove
the node oval shape around the sink nodes and make their text dark
orange. This results in a much more readable output for large graphs.
See the link below for an example.

Link: https://f.jarry.cc/rte-graph-dot/ipv6.svg
Signed-off-by: Robin Jarry <rjarry@redhat.com>
---
 lib/graph/graph.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
  

Comments

Kiran Kumar Kokkilagadda Aug. 29, 2024, 5:47 a.m. UTC | #1
> -----Original Message-----
> From: Robin Jarry <rjarry@redhat.com>
> Sent: Wednesday, August 28, 2024 7:12 PM
> To: dev@dpdk.org; Jerin Jacob <jerinj@marvell.com>; Kiran Kumar Kokkilagadda
> <kirankumark@marvell.com>; Nithin Kumar Dabilpuram
> <ndabilpuram@marvell.com>; Zhirun Yan <yanzhirun_163@163.com>
> Subject: [EXTERNAL] [PATCH dpdk] graph: make graphviz export more readable
> 
> Change the color of arrows leading to sink nodes to dark orange. Remove the
> node oval shape around the sink nodes and make their text dark orange. This
> results in a much more readable output for large graphs. See the link below for an
> example. 
> Change the color of arrows leading to sink nodes to dark orange. Remove the
> node oval shape around the sink nodes and make their text dark orange. This
> results in a much more readable output for large graphs.
> See the link below for an example.
> 
> Link: https://urldefense.proofpoint.com/v2/url?u=https-3A__f.jarry.cc_rte-
> 2Dgraph-
> 2Ddot_ipv6.svg&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=owEKckYY4FTmil1
> Z6oBURwkTThyuRbLAY9LdfiaT6HA&m=D41w8N-
> HiTO9kFbxr3kWwW4TVmWav2Zozr9byDbHSj7TRx6egfC1ut70K2HKJQ0y&s=0gZZ
> VRoev4w7I_KowoRkSn40vymIJgyxS8vBPgEk90c&e=
> Signed-off-by: Robin Jarry <rjarry@redhat.com>
> ---

Acked-by: Kiran Kumar Kokkilagadda <kirankumark@marvell.com>

>  lib/graph/graph.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/graph/graph.c b/lib/graph/graph.c index
> d5b8c9f918cf..dff8e690a80d 100644
> --- a/lib/graph/graph.c
> +++ b/lib/graph/graph.c
> @@ -745,7 +745,7 @@ graph_to_dot(FILE *f, struct graph *graph)
>  			if (rc < 0)
>  				goto end;
>  		} else if (graph_node->node->nb_edges == 0) {
> -			rc = fprintf(f, " [color=darkorange]");
> +			rc = fprintf(f, " [fontcolor=darkorange shape=plain]");
>  			if (rc < 0)
>  				goto end;
>  		}
> @@ -753,9 +753,12 @@ graph_to_dot(FILE *f, struct graph *graph)
>  		if (rc < 0)
>  			goto end;
>  		for (i = 0; i < graph_node->node->nb_edges; i++) {
> +			const char *node_attrs = attrs;
> +			if (graph_node->adjacency_list[i]->node->nb_edges ==
> 0)
> +				node_attrs = " [color=darkorange]";
>  			rc = fprintf(f, "\t\"%s\" -> \"%s\"%s;\n", node_name,
>  				     graph_node->adjacency_list[i]->node-
> >name,
> -				     attrs);
> +				     node_attrs);
>  			if (rc < 0)
>  				goto end;
>  		}
> --
> 2.46.0
  
David Marchand Oct. 11, 2024, 2:44 p.m. UTC | #2
On Wed, Aug 28, 2024 at 3:42 PM Robin Jarry <rjarry@redhat.com> wrote:
>
> Change the color of arrows leading to sink nodes to dark orange. Remove
> the node oval shape around the sink nodes and make their text dark
> orange. This results in a much more readable output for large graphs.
> See the link below for an example.
>
> Link: https://f.jarry.cc/rte-graph-dot/ipv6.svg

Easier to read, thanks.

> Signed-off-by: Robin Jarry <rjarry@redhat.com>

Applied, thanks.
  

Patch

diff --git a/lib/graph/graph.c b/lib/graph/graph.c
index d5b8c9f918cf..dff8e690a80d 100644
--- a/lib/graph/graph.c
+++ b/lib/graph/graph.c
@@ -745,7 +745,7 @@  graph_to_dot(FILE *f, struct graph *graph)
 			if (rc < 0)
 				goto end;
 		} else if (graph_node->node->nb_edges == 0) {
-			rc = fprintf(f, " [color=darkorange]");
+			rc = fprintf(f, " [fontcolor=darkorange shape=plain]");
 			if (rc < 0)
 				goto end;
 		}
@@ -753,9 +753,12 @@  graph_to_dot(FILE *f, struct graph *graph)
 		if (rc < 0)
 			goto end;
 		for (i = 0; i < graph_node->node->nb_edges; i++) {
+			const char *node_attrs = attrs;
+			if (graph_node->adjacency_list[i]->node->nb_edges == 0)
+				node_attrs = " [color=darkorange]";
 			rc = fprintf(f, "\t\"%s\" -> \"%s\"%s;\n", node_name,
 				     graph_node->adjacency_list[i]->node->name,
-				     attrs);
+				     node_attrs);
 			if (rc < 0)
 				goto end;
 		}