我有相对复杂的graphviz输入文件,包含传递关系。 不幸的是,这些使得输出过于复杂而不添加任何其他信息。

有没有简单的方法从输入/输出中去除这些传递关系。

输入示例:

digraph main { 
subgraph cluster_Session_0 {
color = black;
label = "Session_0";
 "Batch_0_0";
}
subgraph cluster_Session_1 {
color = black;
label = "Session_1";
 "Batch_1_0" "Batch_1_1" "Batch_1_2" "Batch_1_3" "Batch_1_4";
}
subgraph cluster_Session_2 {
color = black;
label = "Session_2";
 "Batch_2_0" "Batch_2_1" "Batch_2_2" "Batch_2_3";
}
subgraph cluster_Session_3 {
color = black;
label = "Session_3";
 "Batch_3_0";
}
subgraph cluster_Session_4 {
color = black;
label = "Session_4";
 "Batch_4_0";
}
subgraph cluster_Session_5 {
color = black;
label = "Session_5";
 "Batch_5_0";
}
subgraph cluster_Session_6 {
color = black;
label = "Session_6";
 "Batch_6_0";
}
subgraph cluster_Session_7 {
color = black;
label = "Session_7";
 "Batch_7_0";
}
subgraph cluster_Session_8 {
color = black;
label = "Session_8";
 "Batch_8_0";
}
subgraph cluster_Session_9 {
color = black;
label = "Session_9";
 "Batch_9_0";
}
subgraph cluster_Session_10 {
color = black;
label = "Session_10";
 "Batch_10_0";
}
subgraph cluster_Session_11 {
color = black;
label = "Session_11";
 "Batch_11_0";
}
subgraph cluster_Session_12 {
color = black;
label = "Session_12";
 "Batch_12_0";
}
subgraph cluster_Session_13 {
color = black;
label = "Session_13";
 "Batch_13_0";
}
subgraph cluster_Session_14 {
color = black;
label = "Session_14";
 "Batch_14_0";
}
"Batch_0_0" -> "Batch_1_0";
"Batch_0_0" -> "Batch_1_0";
"Batch_1_0" -> "Batch_1_1";
"Batch_1_1" -> "Batch_1_2";
"Batch_1_2" -> "Batch_1_3";
"Batch_1_3" -> "Batch_1_4";
"Batch_1_4" -> "Batch_2_0";
"Batch_0_0" -> "Batch_2_0";
"Batch_1_4" -> "Batch_2_0";
"Batch_2_0" -> "Batch_2_1";
"Batch_2_1" -> "Batch_2_2";
"Batch_2_2" -> "Batch_2_3";
"Batch_2_3" -> "Batch_3_0";
"Batch_0_0" -> "Batch_3_0";
"Batch_1_4" -> "Batch_3_0";
"Batch_2_3" -> "Batch_3_0";
"Batch_3_0" -> "Batch_4_0";
"Batch_0_0" -> "Batch_4_0";
"Batch_1_4" -> "Batch_4_0";
"Batch_2_3" -> "Batch_4_0";
"Batch_3_0" -> "Batch_4_0";
"Batch_4_0" -> "Batch_5_0";
"Batch_0_0" -> "Batch_5_0";
"Batch_1_4" -> "Batch_5_0";
"Batch_2_3" -> "Batch_5_0";
"Batch_3_0" -> "Batch_5_0";
"Batch_5_0" -> "Batch_6_0";
"Batch_0_0" -> "Batch_6_0";
"Batch_1_4" -> "Batch_6_0";
"Batch_2_3" -> "Batch_6_0";
"Batch_3_0" -> "Batch_6_0";
"Batch_6_0" -> "Batch_7_0";
"Batch_0_0" -> "Batch_7_0";
"Batch_1_4" -> "Batch_7_0";
"Batch_2_3" -> "Batch_7_0";
"Batch_3_0" -> "Batch_7_0";
"Batch_4_0" -> "Batch_7_0";
"Batch_5_0" -> "Batch_7_0";
"Batch_6_0" -> "Batch_7_0";
"Batch_7_0" -> "Batch_8_0";
"Batch_0_0" -> "Batch_8_0";
"Batch_1_4" -> "Batch_8_0";
"Batch_2_3" -> "Batch_8_0";
"Batch_3_0" -> "Batch_8_0";
"Batch_4_0" -> "Batch_8_0";
"Batch_5_0" -> "Batch_8_0";
"Batch_6_0" -> "Batch_8_0";
"Batch_7_0" -> "Batch_8_0";
"Batch_8_0" -> "Batch_9_0";
"Batch_0_0" -> "Batch_9_0";
"Batch_1_4" -> "Batch_9_0";
"Batch_2_3" -> "Batch_9_0";
"Batch_3_0" -> "Batch_9_0";
"Batch_4_0" -> "Batch_9_0";
"Batch_5_0" -> "Batch_9_0";
"Batch_6_0" -> "Batch_9_0";
"Batch_7_0" -> "Batch_9_0";
"Batch_8_0" -> "Batch_9_0";
"Batch_9_0" -> "Batch_10_0";
"Batch_0_0" -> "Batch_10_0";
"Batch_1_4" -> "Batch_10_0";
"Batch_2_3" -> "Batch_10_0";
"Batch_3_0" -> "Batch_10_0";
"Batch_4_0" -> "Batch_10_0";
"Batch_5_0" -> "Batch_10_0";
"Batch_6_0" -> "Batch_10_0";
"Batch_7_0" -> "Batch_10_0";
"Batch_8_0" -> "Batch_10_0";
"Batch_9_0" -> "Batch_10_0";
"Batch_10_0" -> "Batch_11_0";
"Batch_0_0" -> "Batch_11_0";
"Batch_1_4" -> "Batch_11_0";
"Batch_2_3" -> "Batch_11_0";
"Batch_3_0" -> "Batch_11_0";
"Batch_4_0" -> "Batch_11_0";
"Batch_5_0" -> "Batch_11_0";
"Batch_6_0" -> "Batch_11_0";
"Batch_7_0" -> "Batch_11_0";
"Batch_8_0" -> "Batch_11_0";
"Batch_9_0" -> "Batch_11_0";
"Batch_10_0" -> "Batch_11_0";
"Batch_11_0" -> "Batch_12_0";
"Batch_0_0" -> "Batch_12_0";
"Batch_1_4" -> "Batch_12_0";
"Batch_2_3" -> "Batch_12_0";
"Batch_3_0" -> "Batch_12_0";
"Batch_4_0" -> "Batch_12_0";
"Batch_5_0" -> "Batch_12_0";
"Batch_6_0" -> "Batch_12_0";
"Batch_7_0" -> "Batch_12_0";
"Batch_8_0" -> "Batch_12_0";
"Batch_9_0" -> "Batch_12_0";
"Batch_10_0" -> "Batch_12_0";
"Batch_12_0" -> "Batch_13_0";
"Batch_0_0" -> "Batch_13_0";
"Batch_1_4" -> "Batch_13_0";
"Batch_2_3" -> "Batch_13_0";
"Batch_3_0" -> "Batch_13_0";
"Batch_4_0" -> "Batch_13_0";
"Batch_5_0" -> "Batch_13_0";
"Batch_6_0" -> "Batch_13_0";
"Batch_7_0" -> "Batch_13_0";
"Batch_8_0" -> "Batch_13_0";
"Batch_9_0" -> "Batch_13_0";
"Batch_10_0" -> "Batch_13_0";
"Batch_11_0" -> "Batch_13_0";
"Batch_12_0" -> "Batch_13_0";
"Batch_13_0" -> "Batch_14_0";
"Batch_0_0" -> "Batch_14_0";
"Batch_1_4" -> "Batch_14_0";
"Batch_2_3" -> "Batch_14_0";
"Batch_3_0" -> "Batch_14_0";
"Batch_4_0" -> "Batch_14_0";
"Batch_5_0" -> "Batch_14_0";
"Batch_6_0" -> "Batch_14_0";
"Batch_7_0" -> "Batch_14_0";
"Batch_8_0" -> "Batch_14_0";
"Batch_9_0" -> "Batch_14_0";
"Batch_10_0" -> "Batch_14_0";
"Batch_11_0" -> "Batch_14_0";
"Batch_12_0" -> "Batch_14_0";
}

示例输出: 在此输入图像描述

#1楼 票数:7 已采纳

给定来自名为test.dot的文件中的问题的示例点源,来自GraphViz命令行工具的tred工具(用于有向图的传递缩减过滤器)使用以下命令行将其缩减为线性图:

tred test.dot | dot -T png > test.png

结果图片:

  ask by Let_Me_Be translate from so

未解决问题?本站智能推荐:

1回复

如何从graphviz文件中获取边作为列表

我有下面的 .gv 文件,它按预期呈现图形,但我也在尝试获取文件中有多少相关边(不同的树路径) 编辑:添加了更多树节点 期望从上面的树创建下面的列表 有没有办法graphviz可以提供这个信息或任何其他可以帮助解决这个问题的python模块?
1回复

将边权重传递给networkx中的graphviz_layout

大家都找不到如何在networkx中将权重列表的属性名称传递给graphviz_layout。 像这样的东西: 但是使用nx.graphviz_layout(G, ...) 。 也许有人会知道?
4回复

`pydot` 调用 GraphViz 失败。请安装 GraphViz 并确保其可执行文件在 $PATH 中

我的 jupyter 服务器在 gcp 深度学习虚拟机中运行。 我正在尝试在 Jupyter 笔记本单元中打印模型。 我收到这个错误 我已经在我的机器上正确安装了 Graphviz apt-get install graphviz 还安装了 python 包 pydot、pydot-
1回复

Graphviz:将结果写入文件

我有数据框 我尝试用节点创建链并将其写入文件。 我用 它返回 但是我想将其保存到文件中,例如ID 。 我需要获取文件111, 222, 333 。 我尝试 但这是错误的。 它应该返回到具有3个节点的111和333链,但是在文件中,我得到了具有2个到111和33
2回复

如何在Graphviz点文件中插入希腊字符等数学符号?

我有一个独特的问题。 我使用点来表示本质上是通用的图形。 因此,我不打算使用数字,而是计划使用像alpha,beta等希腊字母之类的符号。我很想知道我们如何使用某些符号标记.dot文件中的节点/边缘? 例如,
2回复

GraphViz文件中具有相同属性的节点组

在GraphViz的dot语言中,我想描述一个双模网络。 所以我有两种不同类型的节点。 例如,一个小组可以包含人们如何阅读以及另一个小组可以包含人们正在阅读的书籍。 我想给这两组中的节点赋予不同的外观( shape , color等)。 如何在一个语句中指定一组节点的属性。 目的是
2回复

如何确定Graphviz可执行文件在系统的PATH中?

我正在Sublime Text 3上使用Python 3使用Graphviz。运行此代码时: 我得到这些错误: 似乎找不到所需的文件。 在Sublime Text 3中,我对Conda的用户设置是: { // executable is the path to anacond
1回复

PNG文件未在graphviz点程序中呈现

我想将图像用作嵌入Rmarkdown项目的.dot程序中的节点。 我不知道如何使用DiagrammeR使图像文件出现在输出中。 节点和类似于HTML的标签似乎有效,但IMG属性却无效。 下面是我到目前为止的代码: 这是输出图像: 如何使图像显示在输出中?