summaryrefslogtreecommitdiff
path: root/lib/graph
diff options
context:
space:
mode:
authorRobin Jarry <[email protected]>2024-08-28 15:42:27 +0200
committerDavid Marchand <[email protected]>2024-10-11 17:26:56 +0200
commit5b8d861cfe89ebcbb08760c7817be0b79b9ff6f9 (patch)
tree4a2398b5bf59516a3f0f9ebf14205f2b6457cb9e /lib/graph
parent4acc862b18a2f1691d1561f7b75542f6a056d41f (diff)
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. Link: https://f.jarry.cc/rte-graph-dot/ipv6.svg Signed-off-by: Robin Jarry <[email protected]> Acked-by: Kiran Kumar K <[email protected]>
Diffstat (limited to 'lib/graph')
-rw-r--r--lib/graph/graph.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/graph/graph.c b/lib/graph/graph.c
index d5b8c9f918..dff8e690a8 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;
}