Graphviz/Dot - 如何用独特的颜色标记树中的所有叶子? [英] Graphviz/Dot - how to mark all leaves in a tree with a distinctive color?

查看:24
本文介绍了Graphviz/Dot - 如何用独特的颜色标记树中的所有叶子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个脚本可以将图形打印为 .dot 文件.我想用独特的颜色突出显示所有不同程度的顶点.Graphviz 可以吗?

I have a script which prints a graph as .dot file. I would like to highlight all vertices of different degree with distinctive colors. Is it possible with Graphviz?

所以,我对以下内容感兴趣:

So, I am interested in the following:

For each i-degree vertex use color[i].

作为一种特殊情况,如何用独特的颜色标记树中的所有叶子?:

and as a special case, how to mark all leaves in a tree with a distinctive color? :

For each 1-degree vertex use color_A.

推荐答案

尝试使用 graphviz 实用程序 gvpr 来编写图形脚本.尤其是

Try the graphviz utility gvpr for writing graph scripts. In particular,

gvpr -c 'N[degree==1]{color="red"}'

gvpr -c 'N[degree==1]{color="red"}'

您可以增强它以定义数组(或关联映射)并查找 color[$.degree]

You can enhance this to define an array (or associative map) and look up color[$.degree]

斯蒂芬北

这篇关于Graphviz/Dot - 如何用独特的颜色标记树中的所有叶子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆